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:
-
$table
is the name of the table to investigate, -
$table_spip
is used to automatically replace "spip" by the table’s real prefix; it equalsfalse
by default, -
$serveur
, -
$option
Usage:
$desc = sql_showtable('spip_articles', true);
// $desc['field']['id_article'] = "bigint(21) NOT NULL AUTO_INCREMENT"
// $desc['key']['PRIMARY KEY'] = "id_article"
// $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.
$trouver_table = charger_fonction('trouver_table', 'base');
$desc = $trouver_table('spip_articles');