1
使用wp-load.php在非WordPress核心/插件/模板文件中使用SHOW TABLE STATUS查詢來訪問WordPress函數和數據庫連接。
require_once('wp-load.php');
function mysqlInfo() {
$info = $wpdb->get_results('SHOW TABLE STATUS');
foreach($info as $table) {
echo $table->name;
}
}
我一直運行到這個錯誤:
Fatal error: Call to a member function get_results() on a non-object in /../../../file.php
我曾嘗試宣告$ WPDB作爲一個全局變量,並試圖創建一個新的類出$ WPDB