Database Configuration Settings

You can set configuration options directly using the database object properties or place the configuration in an array that you pass to the database object's connect method.

Configuration Array

Example Configuration Array

$db_config = array(
    //Database connection settings
    'host' => '127.0.0.1',
    'username' => 'root',
    'password' => '',
    'database' => 'dataobjects',
    //Table foreign key hints for automated JOINs
    'foreign_keys' => array(
        'cars' => array(
            'colors_id' => array(  //Link cars.colors_id to color.id
                'name' => 'color', //Use 'color' as the singular name version of the sub-record
                'foreign' => array(
                    'table' => 'colors', 
                    'field' => 'id'
                ),
            ),
            'makes_id' => array(   //Link cars.makes_id to makes.id
                'name' => 'make',  //Use 'make' as the singular name version of the sub-record
                'foreign' => array(
                    'table' => 'makes', 
                    'field' => 'id'
                ),
            ),
        ),
    ),
);

//Connect to the database server using the configuration array
$core->db->connect($db_config);