以下代码中出现以下错误:“对中的非对象调用成员函数get\\u results()”:
require_once($_SERVER[\'DOCUMENT_ROOT\'] . $folder . \'/wp-config.php\');
require_once($_SERVER[\'DOCUMENT_ROOT\'] . $folder . \'/wp-load.php\');
if (!$wpdb) {
$wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
} else {
global $wpdb;
}
function vendorDatails( $param)
{
if ((substr ($param, 0, 0)) == \'#\')
{
substr($param, 1);
}
$order_ids = $wpdb->get_results(
"
SELECT DISTINCT vendor_id
FROM $wpdb->lqrhxf_pv_commission
WHERE order_id = %d
",
$param
);
foreach ( $order_ids as $order_id )
{
echo $order_id->vendor_id;
}
}
db参数已成功加载,但当我使用$wpdb变量时,上面一行出现了错误:
$order_ids = $wpdb->get_results(