Setting up a database connection

The LEAP ORM utilizes the same database configuration file (i.e. config/database.php) as Kohana’s official ORM, Jelly, and Sprig, with a few minor additions/changes:

 1 <?php defined('SYSPATH') OR die('No direct script access.');
 2 $config = array();
 3 $config['default'] = array(
 4     'type'          => 'SQL',       // string (e.g. SQL, NoSQL, or LDAP)
 5     'dialect'       => 'MySQL',     // string (e.g. DB2, Drizzle, Firebird, MariaDB, MsSQL, MySQL, Oracle, PostgreSQL, or SQLite)
 6     'driver'        => 'Standard',  // string (e.g. Standard, Improved, or PDO)
 7     'connection'    => array(
 8         'persistent'    => FALSE,       // boolean
 9         'hostname'      => 'localhost', // string
10         'port'          => '',          // string
11         'database'      => '',          // string
12         'username'      => 'root',      // string
13         'password'      => 'root',      // string
14         'role'          => '',          // string
15     ),
16     'caching'       => FALSE,       // boolean
17     'charset'       => 'utf8',      // string
18 );
19 return $config;

The biggest difference is that ‘type’ now represents the database language category being used. The specific dialect is now specified using the ‘dialect’ setting.

As you can see, there are two additional settings. The first addition is the ‘driver’ setting. This setting allows the user to define which database driver to use: the standard driver (i.e. ‘standard’), the improved driver (i.e. ‘improved’), or the PDO driver (i.e. ‘pdo’). By having a ‘driver’ setting, we can now create additional database driver wrappers with ease. The other addition to this array is the port setting.

Which settings you will use depends on which database you are using and where your database is located. Therefore, not all settings are needed for every database. For example, SQLite does not require a username and password (as well as a few others) whereas MySQL does require these settings.