ci 中使用 pdo 连接 mysql

时间:2022-07-29 15:21:02

ci 版本为 3.0.6

config/database.php 文件内容如下

$active_group = 'default';
$query_builder = TRUE; $db['default'] = array(
'dsn' => '',
'hostname' => 'mysql:dbname=test;host=127.0.0.1',
'username' => 'root',
'password' => '123456',
'database' => 'test',
'dbdriver' => 'pdo',
'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
);