Thursday, 11 February 2016

How to create connectin with database in codeigniter?

How to create the connection with a database in Codeigniter: Connecting with the database in CodeIgniter is very easy you just need to enter few parameters in the database config file that create the connections with the database in CodeIgniter.  The basic parameters that you need to enter are.

How to create connectin with database in codeigniter?


  • Hostname
  • Username
  • Password
  • Database
What is hostname, username, password and database: The hostname is the server address that is the IP address and the hostname is assigned to that specific IP with a name is called hostname. The example in the local server name is localhost.  username of the server like in apache server by default user is the root user in local host and the password of the user root is nothing empty. The database you create in the localhost/PHPMyAdmin creates new database with the name you like to create that will be your database. These are the parameters that you must need to set for the database connections. Two syntaxes you can write in array

$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => 'mypassword',
'database' => 'datingSite',
'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
);
or you can also write like this
 $db['default']['hostname'] = 'localhost';
 $db['default']['username'] = 'root';
 $db['default']['password'] = 'mypass';
 $db['default']['database'] = 'datingSite';

How to create connectin with database in codeigniter?

Simple and easy to connect with database. For your information, you can connect multiple databases in one project application system. Like one database of "Employees" and other databases of "Passports," these two separate databases can be used at a time in one application system in software development process and it is a legal way, You can use it like this. If you have any problem you can ask here in the comment box We will response you. For further reading, you can read the pagination that is the next step.
How to create pagination in Codeigniter...!

This Post Was Last Updated On September 30, 2016, By Author: Mahira Khan.

0 comments:

Post a Comment

Item Reviewed: How to create connectin with database in codeigniter? Rating: 5 Reviewed By: admin