Unknown Database Configuration in Codeigniter |Codeigniter tutorial for beginners step by step in hindi | My Project HD
X

Database Configuration in Codeigniter |Codeigniter tutorial for beginners step by step in hindi

Database Configuration in Codeigniter |Codeigniter tutorial for beginners step by step in hindi





in this tutorial we will Discuss about how to configure database in codeigniter . for configure database in codeigniter you can open config/database.php file 
in config/database.php file you can set follwing values 

What Is Database :

Database is library in codeigniter . database library used in codeigniter for communicate with database.this library provide you many features to communicate with database

 

 

'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => 'mypro_ci_tutorial',

 

$db['default'] = array(
    'dsn'    => '',
    'hostname' => 'localhost',
    'username' => 'root',
    'password' => '',
    'database' => 'mypro_ci_tutorial',
    'dbdriver' => 'mysqli',
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' => (ENVIRONMENT !== 'production'),
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE
);

 

How To Load Database 

There are the following ways to load the database in codeigniter

1. autoload.php 

in codeigniter you can load database library in autoload.php file. in autoload.php file you can load database library in library array .this library accessible in complete codeigniter project


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

 

2. Current Controller Constructor :

you can load database library . in current controller constructor using following code .this library accessible only current controller

punlic function __construct()
{
  parent::__construct();
  $this->load->library('database');
}

 

More Tutorials

Web Technology Tutorials in Hindi

Web Technology Tutorials in Hindi

Read More
Diploma engineering tutorial for polytechnic collage

Diploma Engineering Tutorial

Read More
Final Year Projects for Computer Science with Source Code

Final Year Projects for Computer Science with Source Code

Read More

Related Tutorials