There are two ways to connect with the database:
- Automatically connect
- Manually 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');
If you want to load the database on some pages you can connect by adding the following line:
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);