The sql_replace_multi() function is used to insert or replace several rows (which have the same schema) for an SQL table in a single operation. The values are automatically filtered against SQL injection attacks. It is necessary that the columns of inserted pairs contain the primary key(s) for that table.

It is recommended to use the specific functions sql_insertq_multi() and sql_updateq() instead of this function to be more precise, at least where such is possible.

It has the same 5 parameters as sql_replace :

  1. $table is the SQL table in question,
  2. $couples is a table of column/value pairs to be modified,
  3. $desc,
  4. $serveur,
  5. $option.

It is used as shown below:

sql_replace_multi('table', array(
        'column' => 'value1',
        'id_table' => $id1
        'column' => 'value2',
        'id_table' => $id2

Author Mark Baber Published : Updated : 01/06/10

Translations : English, français