Coding with SPIP 2.1
SPIP 2.1 Technical Documentation

> > > > sql_showtable


The sql_showtable() functions returns a description of an SQL table in an associative array that lists the columns and their SQL "field" descriptions and also listing the keys. Whenever a join declaration exists for the table declared in tables_principales or tables_auxiliaires, the array will also include an entry for the "join" key.

Its parameters are:

  1. $table is the name of the table to investigate,
  2. $table_spip is used to automatically replace "spip" by the table’s real prefix; it equals false by default,
  3. $serveur,
  4. $option


  1. $desc = sql_showtable('spip_articles', true);
  2. // $desc['field']['id_article'] = "bigint(21) NOT NULL AUTO_INCREMENT"
  3. // $desc['key']['PRIMARY KEY'] = "id_article"
  4. // $desc['join']['id_article'] = "id_article"


In most situations, it would be better to use the trouver_table function, which has a cache on the data structure, use the sql_showtable() function and add some supplementary information.

  1. $trouver_table = charger_fonction('trouver_table', 'base');
  2. $desc = $trouver_table('spip_articles');


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