You Can use This solution..
How to delete all records from or empty a custom database table?
In this solution First delete all records an then insert new records
(your table should be have records before to delete query because If run $delete you give error ‘No find row’ ) and No need to use replace
I us insert
add this following query before your function. (this query delete all records )
$delete = $wpdb->query("TRUNCATE TABLE `wp_table_name`");
$delete = $wpdb->query("TRUNCATE TABLE `wp_table_name`"); /// delete all records
$wpdb->insert( $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'
) );
run foreach
Note: If your code is in a loop you should insert this query before loop.
$delete = $wpdb->query("TRUNCATE TABLE `wp_table_name`");
foreach (){
// code
}