CodeIgniter mysqli - 遇到错误无效的数据库驱动程序

时间:2016-10-19 02:06:18

标签: codeigniter

如果我将dbdriver从mysqli更改为mysql它正在工作但不在mysqli中 会出现什么问题?

database.php - 数据库配置

$active_group = 'default';
$query_builder = TRUE;
$db['default'] = array(
    'dsn'   => '',
    'hostname' => 'localhost',
    'username' => '',
    'password' => '',
    'database' => '',
    'dbdriver' => 'mysqli',
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' => FALSE,
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE
);

2 个答案:

答案 0 :(得分:0)

请确保在Apache中安装并启用了MySQLi驱动程序。

答案 1 :(得分:0)

为您提供三种解决方案

  1. 确保已安装php-mysqli并在apache中启用。
  2. 检查Codeigniter的系统目录。如果该位置不存在mysql / mysqli目录,则从新的codeigniter复制它。
  3. 将驱动程序从mysqli切换到pdo

    $active_group = 'default';
    $query_builder = TRUE;
    $db['default'] = array(
      'dsn'   => 'pgsql:host=localhost;port=3306;dbname=myproject',
      'hostname' => 'localhost',
      'username' => 'root',
      'password' => '*******',
      'database' => 'myproject',
      'dbdriver' => 'pdo',
      'dbprefix' => '',
      'pconnect' => FALSE,
      'db_debug' => FALSE,
      'cache_on' => FALSE,
      'cachedir' => '',
      'char_set' => 'utf8',
      'dbcollat' => 'utf8_general_ci',
      'swap_pre' => '',
      'encrypt' => FALSE,
      'compress' => FALSE,
      'stricton' => FALSE,
      'failover' => array(),
      'save_queries' => TRUE
    );
    

您可以阅读参考文章中的完整教程。

https://mytechnode.com/invalid-db-driver-in-codeigniter-mysqli/