Codeigniter Connect Database
Codeigniter Connect Database : You can connect to database in codeigniter as below.
Steps : Codeigniter Connect Database
Go to the application/config/databse.php
Step 1
Go to the below lines:
$db['default'] = array( 'dsn' => '', 'hostname' => 'localhost', 'username' => 'username', 'password' => 'password', 'database' => 'your_databse_name', 'dbdriver' => 'mysqli', 'dbprefix' => '', 'pconnect' => FALSE, 'db_debug' => TRUE, 'cache_on' => FALSE, 'cachedir' => '', 'char_set' => 'utf8', 'dbcollat' => 'utf8_general_ci', 'swap_pre' => '', 'encrypt' => FALSE, 'compress' => FALSE, 'stricton' => FALSE, 'failover' => array(), 'save_queries' => TRUE );
Add the above required parameter –
Hostname, Database Username and Password, Database name and other options if you need.
Step 2
Go to application/config/autoload.php
Go on the line :
$autoload['libraries'] = array();
Now Add
$autoload['libraries'] = array('database');
Advertisements