Introduction
There are two ways to connect with the database:
- Automatically connect
- Manually connect
Automatically connect
The “auto-connect” feature will load and instantiate the database class with every page load. To enable “auto connecting”, add the word database to the library array in the applications/config/autoload.php file.
$autoload['libraries'] = array('database');
Manually Connect
If you want to load the database in some pages you can connect by adding the following line:
$this->load->database();
Connecting to Multiple Databases
It is possible to connect more than one database. See the following example.
$DB1 = $this->load->database('group_one', TRUE);
$DB2 = $this->load->database('group_two', TRUE);