Coding with SPIP 2.1
SPIP 2.1 Technical Documentation

> > > > sql_insert

sql_insert

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:

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

Example

Insert a link to a keyword for an article:

  1. $id_mot = intval($id_mot);
  2. $article = intval($article);
  3. sql_insert("spip_mots_articles", "(id_mot, id_article)", "($id_mot, $article)");

Download

Example of migrating to sql_insertq():

  1. sql_insertq("spip_mots_articles", array(
  2. "id_mot" => $id_mot,
  3. "id_article" => $article));

Download

  • Author :
  • Published :
  • Updated : 02/06/10
  • Translations : English, français