Table updates and installation

When SPIP installs itself, it uses particular functions to install or update its tables. Plugins may also use these functions in their own installation routines.

These functions are declared in the ecrire/base/create.php file.

Creating tables

The creer_base($connect='') function creates tables missing in the database which has the connection file specified in $connect. By default, this is the principal connection.

This function creates the missing tables (of course, they must have already been defined), but does nothing for modifying an existing table. If the table is declared as a principal table (and not an auxiliary table), and if the primary key is an integer, then SPIP will automatically assign an ’auto-increment’ type to this primary key.

Updating tables

The maj_tables($tables, $connect='') function updates existing tables. It will only create fields that are missing; no field deletion will be performed. The table name (character string) or list of table names (table) must be provided to the function. There again, it is possible to specify a different connection file other than the principal database.

If a table to be updated does not exist, it will be created, following the same principle as creer_base() does for the auto-increment.



Author Mark Baber Published : Updated : 12/03/23

Translations : English, français, Nederlands