我尝试在 Yii 1.1.x 中使用 CDbHttpSession,但是当我在 main.php 中从 CHTTPSession 更改它时,我得到出现以下错误:
CDbConnection failed to open the DB connection: could not find driver
我在 Linux 服务器上成功安装了 PDO 驱动程序,无论如何我都可以连接到数据库,只有当我尝试使用 CDbHttpSession 时才会出现此错误。 我还在 php.ini 中允许使用 PDO 扩展:
extension=pdo.so
extension=pdo_mysql.so
我安装了 php5-mysql,当然我还重新启动了 apache2。
我的 main.php 中有以下内容:
'components' => array(
...
'session' => array(
'class' => 'CDbHttpSession',
),
...
'db' => array(
'connectionString' => 'mysql:host=localhost;dbname=databasename',
'emulatePrepare' => true,
'username' => 'username',
'password' => 'password',
'charset' => 'utf8',
'tablePrefix' => '',
),
...
),
预先感谢您的帮助解答。
最佳答案
你需要指定连接 ID,否则 Yii 会尝试使用 SQLite,而你显然没有它的驱动程序。
'session' => array(
'class' => 'CDbHttpSession',
'connectionID' => 'db',
),
关于php - Yii 1.1.x CDbHttpSession 错误 : CDbConnection failed to open the DB connection: could not find driver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40608808/