Coding with SPIP 2.1
SPIP 2.1 Technical Documentation

> > > > Declaring another database

Declaring another database

In order to access another database, SPIP needs to have access codes to that database. At the time of writing, secondary declared databases are correctly handled in read mode. Writing to such databases, however, is not yet handled by SPIP 2.

To declare another database, there are two possible solutions:

  • use the standard graphical interface defined for that purpose (Configuration > Site maintenance > Declare another database)
  • write your own connector file following the syntax defined for that purpose, and store it in the config/ directory (or the directory defined by the constant _DIR_CONNECT).

The connector file config/xx.php

For a connector file called tarabiscote.php, its content would be:

  1. <?php
  2. if (!defined("_ECRIRE_INC_VERSION")) return;
  3. define('_MYSQL_SET_SQL_MODE',true);
  4. $GLOBALS['spip_connect_version'] = 0.7;
  5. spip_connect_db('localhost','','username','password','tarabiscote','mysql', 'spip','');
  6. ?>


We would then call the spip_connect_db() function using the following arguments in that order:

  1. the address of the sql server
  2. the connecting port number, if necessary
  3. the username
  4. the password
  5. the database name
  6. the server type (mysql, pg, sqlite2, sqlite3...)
  7. the table prefix
  8. are users connected using ldap ?
  • Author :
  • Published :
  • Updated : 03/07/10
  • Translations : English, français