Doesn't Update all fields of wordpress table with ON DUPLICATE KEY UPDATE command

I write code with $wpdb->insert comand in to the my wordpress database table (Names is wp_coin_price) . after inserted data in the table, then I write code to update all fields with ON DUPLICATE KEY UPDATE But I don’t know why its cant update fields … please help

 $wpdb->insert( $wpdb->prefix . 'coin_price', 
array( 
'title' =>  trim($row->item(0)->nodeValue) ,
'liveprice' =>  trim($row->item(2)->nodeValue)  ,
 'changing' =>   trim($row->item(4)->nodeValue)  ,
 'lowest' =>   trim($row->item(6)->nodeValue)  ,
'topest' =>   trim($row->item(8)->nodeValue)  ,
'time' =>   trim($row->item(10)->nodeValue)   ), 
array( 
 '%s',
 '%s',
 '%s',
 '%s',
 '%s',
 '%s'
 ) )."ON DUPLICATE KEY UPDATE 
  titile = VALUES('title' =>  trim($row->item(0)->nodeValue)     ) ,
 liveprice = VALUES('liveprice' =>  trim($row->item(2)->nodeValue) ) ,
 changing = VALUES('changing' =>   trim($row->item(4)->nodeValue) ) ,
 lowest = VALUES('lowest' =>   trim($row->item(6)->nodeValue)   ) ,
 topest = VALUES('topest' =>   trim($row->item(8)->nodeValue)   ) ,
 time =  VALUES('time' =>   trim($row->item(10)->nodeValue)    )";

Are you sure your close parenthesis is in the correct place? Also that your query string appears to have several references to variables that wont exist inside the execution space?

As per the documentation insert will insert the specified values. What you are doing is concatenating a string onto the end of the return value of the insert method. What your actually after is the replace method.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.