The sql_insert() function is used to insert content into a database. The SQL ports may experience problems when using this function, and if so, they should use the sql_insertq() function instead. This function is described here only to ensure support for restoring old backups and for transitioning old scripts.

The function accepts 6 parameters:

  1. $table is the SQL table,
  2. $noms is the list of columns affected,
  3. $valeurs is the list of values to be stored,
  4. $desc,
  5. $serveur,
  6. $option.

Usage example:

sql_insert('table', '(column)', '(value)');


Insert a link to a keyword for an article:

$id_mot = intval($id_mot);
$article = intval($article);
sql_insert("spip_mots_articles", "(id_mot, id_article)", "($id_mot, $article)");

Example of migrating to sql_insertq():

sql_insertq("spip_mots_articles", array(
	"id_mot" => $id_mot, 
	"id_article" => $article));

Author Mark Baber Published : Updated : 12/03/23

Translations : English, français