I write code to save data in to the database table.
I want Replace a row in a table if it exists or insert a new row in a table if the row did not already exist.
http://codex.wordpress.org/Class_Reference/wpdb
I use $wpdb->replace
function and then add $wpdb->insert_id
to end of code.
But when run my own wordpress plugin . only add new rows with values .Can't replace values.
$wpdb->replace( $wpdb->prefix . 'fafa',
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'
) );
$wpdb->inser_Id;
table photo
In Following photo Now id is Unique