If you have already configured CodeIgniter to connect with a database, you can skip this part, as all we're going to do is make sure we can connect to a database; to do this, we're going to amend the following two files:
/path/to/codeigniter/application/config/database.php
/path/to/codeigniter/application/config/autoload.php
database.php
config file, look for the following lines and amend them accordingly:$db['default']['hostname'] = 'localhost'; $db['default']['username'] = 'Replace with database username'; $db['default']['password'] = 'Replace with database password'; $db['default']['database'] = 'Replace with database name';
The chances are that you'll not need to change $db['default']['hostname']
from the 'localhost'
, and replace other values (username
, password
, and database
) with the specific values for your environment.
autoload.php
config file, look for the following line (around line 55):$autoload['libraries'] = array();
$autoload
array like this:$autoload['libraries'] = array('database'),
There's not a lot to this really; it's only setting the configuration settings, but one interesting point is that of autoloading the libraries. By placing a library name in this array in the autoload configuration file, you no longer need to load the library explicitly in a controller later in your application.
18.224.33.107