Welcome Guest, Not a member yet? Register   Sign In
Need Help .......
#1

[eluser]Unknown[/eluser]
Hi,

I have downloaded the "CodeIgniter_2.1.3", but I am not finding the file containing the class (CI_DB)for database connectivity which is supposed to be under folder "application/libraries".

Can anybody help me on this... it is urgent......:-S
#2

[eluser]CroNiX[/eluser]
That is a core class with it's own driver, located in /system/database

Anything in /application would be your own application specific things, like your controllers, configs, libraries, models, etc., not the CORE CI classes.
#3

[eluser]Unknown[/eluser]
Hi CroNiX,

then how to load the database connectivity class. Every sample code is telling to load the database class in "autoload.php" using code

$autoload['libraries'] = array('database','session');

then use the following to connect to DB

$this->load->database('proj');

Please correct me if I am wrong. Please if possible send some sample code for the same. It is urgent ......
#4

[eluser]Ckirk[/eluser]
If you look at your config file "application/config/database.php" by default you will see the variable:
Code:
$active_group = 'default';
Underneath that you will see all the parameters for the 'default' group.
Code:
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = '';
$db['default']['database'] = 'yourdatabase';
$db['default']['dbdriver'] = 'mysql';
....................................

You've set 'database' to load in your autoload so your CI application will automatically do:
Code:
$this->db->load('default')
so you don't have to

When you use $this->db->load() with no input parameter it uses the group as defined by the $active_group variable (which is what the autoload will handle).
You're asking it to override that variable and load the database group called 'proj' so you must have that in your config file, otherwise it will fail. If 'proj' is the only database group you'll ever connect to then just set
Code:
$active_group = 'proj';
and add in the database group
Code:
$db['default']['hostname'] = 'localhost';
$db['proj']['username'] = 'root';
$db['proj']['password'] = '';
$db['proj']['database'] = 'yourdatabase';
$db['proj']['dbdriver'] = 'mysql';
....................................
There's no real need to change everything to proj though. I'd just leave it all at default and run with that





Theme © iAndrew 2016 - Forum software by © MyBB