Sunday 15 July 2012

php - wpdb->query prepare doesn't work -


I followed the introduction to use to prepare some data in the table to prepare.

The code is as follows:

  $ wpdb-> Query ($ wpdb- & gt; Ready ("INSERT {$ wpdb-> prefix} awpcp_adphotos VALUES (Ad_id, image_name, disabled, isprimary) (% d,% s,% d,% d)", $ ad_id, $ Ad_img, 0, 0));   

In addition, disabled and is_primary must be boolean, but I'm not sure what the data type is here.

I also tried

  $ wpdb-> Insert ('$ $ wpdb- & gt; prefix} awpcp_adphotos', // table name array ('ad_id' = & gt; $ Ad_id, 'image_name' = & gt; $ ad_img, 'disabled' => 0 , 'Is_primary' = & gt; 0,), // column array ('% s', '% d', '% d', '% D') // clear formatting   );  

But no luck has been found so far.

(?):

  $ wpdb-> gt; ; Query ($ wpdb- & gt; ("INSERT {$ wpdb-> prefix} APCP_Adphatos (` ad_id`, `image_name`,` disabled`, `patterned`) value (% d,% s,% d,% D) ", $ ad_id, $ Ad_img, 0, 0));   

I think that you have mistakenly written the whole thing wrong, :)

For your edit, if insert () Should be used like:

  $ wpdb-> Insert ($ wpdb-> prefix. 'APPCPADFotos', array ('ad_id' = & gt; $ ad_id, 'image_name' = & gt; $ image_name, 'disabled' = & gt; $ disabled, 'isprimary' = & Gt; $ isprimary,));    

No comments:

Post a Comment