CodeIgniter PDO database driver not working

前端 未结 4 808
梦如初夏
梦如初夏 2021-01-04 09:35

I\'m trying to use the PDO MySQL driver in my CodeIgniter application. This is my database config:

$active_group = \'default\';
$active_record = TRUE;

$db[\         


        
4条回答
  •  一向
    一向 (楼主)
    2021-01-04 09:53

    According to CodeIgniter's Database Configuration page,

    For the PDO driver, you should change the 'hostname => 'localhost'' to "'hostname' => mysql:host=localhost" like below:

    $db['default'] = array(
        'dsn'   => '',
        'hostname' => 'mysql:host=localhost',
        'username' => 'root',
        'password' => '',
        'database' => 'database_name',
        'dbdriver' => 'pdo',
        'dbprefix' => '',
        'pconnect' => FALSE,
        'db_debug' => (ENVIRONMENT !== 'production'),
         .....
         .....
    );
    

提交回复
热议问题