I am trying to write a query to insert an array of many values (say 1000) in a effective way using 'implode'. Here is the code.
$sql = array();
foreach( $return as $key=>$row ) {
$sql[] = '("'.mysql_real_escape_string($row['fullname']).'", '.$row['age'].','.$row['since'].','.'"'.mysql_real_escape_string($row['description']).'")';
}
mysql_query('INSERT INTO data (name, age, since, description) VALUES '.implode(',', $sql));
My query inserts the record array into the data
table. I want to change the query so that it will update the record if it exists, and otherwise it will insert the record.