Coding with SPIP 2.1
SPIP 2.1 Technical Documentation

> > > > sql_delete

sql_delete

The sql_delete() function is used to delete records from an SQL table and returns the number of records that were all deleted.

It has 4 parameters:

  1. $table is the name of the SQL table,
  2. $where,
  3. $serveur,
  4. $option.

It is used as shown below:

  1. sql_delete('table', 'id_table = ' . intval($id_table));

Example

Delete the link between all sections and a given keyword:

  1. sql_delete("spip_mots_rubriques", "id_mot=$id_mot");

One of SPIP’s standard periodical tasks is to delete old articles that have been put in the dustbin (poubelle), as detailed below:

  1. function optimiser_base_disparus($attente = 86400) {
  2. $mydate = date("YmdHis", time() - $attente);
  3. // ...
  4. sql_delete("spip_articles", "statut='poubelle' AND maj < $mydate");
  5. }

Download

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