MySource Matrix Resources

Main Content

Annotated db.inc

Introduction

The db.inc file is the database configuration file for MySource Matrix. The database name, type, and credentials required to connect to the MySource Matrix database are specified in this file.

This file must be configured prior to running step_02.php when installing MySource Matrix, however the file itself can be modified any time thereafter without running the steps again. This is also the only way to modify database connection details as this information is not exposed on any backend interfaces.

This information does not provide details regarding database setup or configuration for database replication as these are specific to each implementation.

The table below lists the db.inc configuration settings for MySource Matrix.

This list of configuration variables is current as of version 3.22.1. Earlier versions will not have all of these variables in the db.inc file. Please note that all database configuration in releases prior to 3.18.0 are stored in the main.inc configuration file.

Database Configuration Settings

Main Database Connections

MySource Matrix has three main database connections which are used for asset operations. These are as follows:

  • db1: used for read-only operations (SELECT queries)
  • db2: write operations (INSERT, UPDATE, DELETE) and anything using transactions (ie; using BEGIN / COMMIT / ROLLBACK statements)
  • db3: quick-fire read/write operations, usually configured with db2 details but with a different username

The db3 connection is used for operations such as locking, non-transactional and critical operations. As such, queries executed on db3 are meant to be very quick. If the same host and database details as specified in db2 are used for this connection, a different username should be used for db3 to avoid reuse of an open db2 connection.

Connection Specification

There are a number of settings for each connection which are explained below.

  • DSN: a hostname/database name specification in the format 127.0.0.1/matrix_db
  • user: the username used to connect to the database
  • password: the password used to connect to the database
  • type: either 'oci' for Oracle or 'pgsql' for PostGres
  • persistent: whether or not to make the connection persistent. Set to TRUE (without quotes) to enable this option. If this option is not specified, the database connection will be only used once (ie; not persistent)

Further settings for Oracle databases only:

  • encoding: the character encoding for the database (eg; AL32UTF8)

Further Database Connections for load balancing

Two optional connections, dbcache and dbsearch, can be used to offload the database calls for the Matrix cache and search functions to a separate database. The specified database may reside on a separate host.

The configuration structure for these databases is the same as for the db1-3 connections. When set to NULL, the Matrix database specified under the db2 connection will be used for cache operations and the connection specified as db used for search operations, as per the default Matrix configuration.

Database Configuration File examples

Oracle
$db_conf = array (
        'db' => array (
                'DSN'       => '127.0.0.1/matrix_db',
                'user'      => 'matrix_user',
                'password'  => 'db_pass',
                'type'      => 'oci',
                'encoding'  => 'AL32UTF8',
                'persistent'=> TRUE,
               ),
        'db2' => array (
                'DSN'       => '127.0.0.1/matrix',
                'user'      => 'matrix_user',
                'password'  => 'db_pass',
                'type'      => 'oci',
                'encoding'  => 'AL32UTF8',
                'persistent'=> TRUE,
               ),
        'db3' => array (
                'DSN'       => '127.0.0.1/matrix',
                'user'      => 'matrix_user_secondary',
                'password'  => 'db_pass',
                'type'      => 'oci',
                'encoding'  => 'AL32UTF8',
               ),
        'dbcache' => NULL,
        'dbsearch' => NULL,
        );

return $db_conf;
PostGres
$db_conf = array (
        'db' => array (
                'DSN'      => 'pgsql:dbname=matrix_db',
                'user'     => 'matrix_user',
                'password' => 'db_pass',
                'type'     => 'pgsql',
               ),
        'db2' => array (
                'DSN'      => 'pgsql:dbname=matrix_db',
                'user'     => 'matrix_user',
                'password' => 'db_pass',
                'type'     => 'pgsql',
               ),
        'db3' => array (
                'DSN'      => 'pgsql:dbname=matrix_db',
                'user'     => 'matrix_user_secondary',
                'password' => 'db_pass',
                'type'     => 'pgsql',
               ),
        'dbcache' => NULL,
        'dbsearch' => NULL,
        );

return $db_conf;