开发者

Codeigniter Manual Database Connection

I am doing php in Codeigniter framework.Always Codeigniter support default persistent connections.I don't want to use that connection.I need to connect manually.Is it possible in Codeigniter? If anybody know please help me to go fo开发者_如何学Crward.I need little bit explanation also please.


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


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
);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜