1

How do 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

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.