Connecting Database in codeigniter 2.02
How do开发者_Go百科 i connect database in codeigniter because there is not any core array in autoload.php i am trying to search it there not any core array as like pervious version
In application/config/database.php you place the settings to connect to your DB, for ex:
$db['default']['hostname'] = '127.0.0.1';
$db['default']['username'] = '';
$db['default']['password'] = '';
$db['default']['database'] = '';
$db['default']['dbdriver'] = 'mysql';
//and so on...
Then, you might want to autoload it to have always at hand and avoid calling the library often. You put it in the
$autoload['libraries'] = array('database');
which is on line 55 of application/config/autoload.php
Then you can just call it in any controller or method (or custom libraries) with
//$this->db->... // method may vary
look in User Guide on database driver for all details and methods and the useful Active Record (sortof), and if you've problem just ask.
精彩评论