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');
}
Related Tutorials
Tutorial Topics
- Intorducation of Codeigniter Tutorial - Codeigniter Tutorial For Beginners Step By Step in Hindi
- What is Codeigniter And What Is Framework - Codeigniter Tutorial For Beginners Step By Step in Hindi
- how to install codeigniter in xampp windows -Codeigniter Tutorial For Beginners Step by Step in Hindi
- Codeigniter Application Architecture - Codeigniter Directory Structure-Codeigniter Tutorial for Beginners Step by Step in Hindi
- What is MVC Architecture - Codeigniter Tutorial for Beginners Step by Step in Hindi
- Basic Component Of Codeigniter - Codeigniter tutorial for beginners step by step in hindi
- How to set Base url in Codeigniter Config File| Codeigniter tutorial for beginners step by step in hindi
- Database Configuration in Codeigniter |Codeigniter tutorial for beginners step by step in hindi
- How to Load Library | Model | Helper in Codeigniter | Autoload files | Codeigniter tutorial for beginners step by step in hindi
- How to Remove Index.PHP in Codeigniter using htaccess - Codeigniter tutorial for beginners step by step in hindi
- What is Helper in Codeigniter - Codeigniter tutorial for beginners step by step in hindi
- What is URL Helper in codeigniter - What is Helper in Codeigniter - Codeigniter tutorial for beginners step by step in hindi