Codeignitor Manual Database Connection

0 votes
asked Apr 28, 2010 by abhis

I am doing php in codeignitor framework.Always codeignitor support default persistent connections.I dont want to use that connection.I need to connect manually.Is it possible in codeignitor?If anybody know please help me to go forward.I need little bit explanation also please.

2 Answers

0 votes
answered Apr 28, 2010 by turbod

if you want not persistent connection, set up the config file.

$config['hostname'] = "localhost";
$config['username'] = "myusername";
$config['password'] = "mypassword";
$config['database'] = "mydatabase";
$config['dbdriver'] = "mysql";
$config['dbprefix'] = "";

$config['pconnect'] = FALSE;

$config['db_debug'] = TRUE;
$config['cache_on'] = FALSE;
$config['cachedir'] = "";
$config['char_set'] = "utf8";
$config['dbcollat'] = "utf8_general_ci";

$this->load->database($config);


You can read more in http://codeigniter.com/user_guide/database/connecting.html

0 votes
answered Sep 15, 2017 by abhishek-gawande

You have to update the file in application/config/databse.php

The values depend on the specific environment.For example, when using SQLite you will not need to supply a username or password, and the database name will be the path to your database file.

If you are using xampp server keep the password field blank.

$active_group ='default';
$query_builder = TRUE;

$db['default'] = array(
    'dsn'   => '',
    'hostname' => 'localhost',
    'username' => 'root',
    'password' => '',
    'database' => 'test',
    '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
);
Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter

...