This pipeline declares additional tables or fields. The SQL type of each field is specified, along with the primary keys and sometimes the secondary keys (used for joins between tables).

The tables in question are the "principal" ones because they mainly concern editorial content, whereas "auxiliary" tables relate to links between those principal tables.

These declarations are used by SPIP to:

  • manage the display of loops (even if it’s optional because SPIP can get the SQL description of a table that hasn’t been declared),
  • create tables (or new fields) during the installation of SPIP or a plugin,
  • backup and restore these tables with the default backup manager in SPIP’s private area.

The function receives as arguments the list of the tables already declared and returns this same array, now supplemented. In this array, each table is declared with an associative array of 3 keys (the join key is actually optional):

$tables_principales['spip_name'] = array(
	'field' => array('champ'=>'SQL creation code'),
	'key' => array('type' => 'name(s) of the field(s)'),
	'join' => array('champ'=>'join field')   // Optional key

SPIP uses this pipeline in the last part of the declaration of the tables that will be used


The "Agenda" plugin declares a table of events, "spip_evenements", with a number of fields. It declares the primary key (id_evenement), 3 indices (date_debut, date_fin and id_article), as well as two possible keys for use in joins: id_evenement and id_article (the order of these declared keys determines their priority when establishing joins).

It also declares an "agenda" field in the spip_rubriques table:

function agenda_declarer_tables_principales($tables_principales){
	//-- Table EVENEMENTS -------------------
	$evenements = array(
		"id_evenement"	=> "bigint(21) NOT NULL",
		"id_article"	=> "bigint(21) DEFAULT '0' NOT NULL",
		"date_debut"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
		"date_fin"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
		"titre"	=> "text NOT NULL",
		"descriptif"	=> "text NOT NULL",
		"lieu"	=> "text NOT NULL",
		"adresse"	=> "text NOT NULL",
		"inscription" => "tinyint(1) DEFAULT 0 NOT NULL",
		"places" => "int(11) DEFAULT 0 NOT NULL",
		"horaire" => "varchar(3) DEFAULT 'oui' NOT NULL",
		"id_evenement_source"	=> "bigint(21) NOT NULL",
		"maj"	=> "TIMESTAMP"
	$evenements_key = array(
		"PRIMARY KEY"	=> "id_evenement",
		"KEY date_debut"	=> "date_debut",
		"KEY date_fin"	=> "date_fin",
		"KEY id_article"	=> "id_article"
	$tables_principales['spip_evenements'] = array(
		'field' => &$evenements, 
		'key' => &$evenements_key, 

	$tables_principales['spip_rubriques']['field']['agenda'] = 'tinyint(1) DEFAULT 0 NOT NULL';

	return $tables_principales;

Author Gilles Vincent Published : Updated : 12/03/23

Translations : English, Español, français