0
試圖運行使用WordPress SQL查詢WPDB調用一個成員函數準備() - WordPress的WPDB,SQL quert
global $wpdb;
$sql = $wpdb->prepare("INSERT INTO $wpdb->wp_advert_management(`category_id`,`sub_category_id`,`third_level_sub_category_id`,`fourth_level_sub_category_id`,`model_year`, `car_name`, `registration`, `milage`, `fuel_type_id`, `transmision_type_id`, `price`, `location`, `description`, `created_date`, `modified_date`, `created_by`, `created_ip`, `modified_ip`, `user_id`, `is_active`, `phonenumber`)
VALUES ('".$category_id."','".$sub_category_id."','".$third_level_sub_category_id."','".$fourth_level_sub_category_id."','".$model_year."','".$car_name."','".$registration."','".$milage."',
'".$fuel_type_id."','".$transmision_type_id."','".$price."','".$location."',
'".$description."','".$date."','".$modified_date."','".$created_by."','".$created_ip."','','".$user_id."','".$is_active."','".$phonenumber."')");
$wpdb->query($sql);
返回被調用一個成員函數準備(錯誤),似乎是PDO錯誤?
我是不是要包括在WordPress額外的文件,從文檔該查詢看上去正確
,或者我應該只使用wpdb->插入不準備?
對不起已滿錯誤
呼叫一個成員函數準備()嘗試這種
global $wpdb;
$wpdb->insert("wp_advert_management", array(
"category_id" => $category_id,
));
相同的錯誤呼叫成員函數的非對象
上製備()在非-object
有人可以解釋錯誤嗎?這樣我就可以看固定
的準備方法是沒有問題的,它的PDO的實例,其內部沒有'$ wpdb' – Ghost 2014-09-26 12:02:27
* ......一個非對象* , 對?爲什麼你忽略了一半的錯誤信息? – deceze 2014-09-26 12:03:24
您誤解了'prepare()'方法,就像使用'sprintf()'。但首先,你在哪裏使用這段代碼?我想你不會在'functions.php'文件中的任何鉤子中使用它?我也不確定'$ wpdb-> wp_advert_management'是否適合你。 – birgire 2014-09-26 12:12:57