gpt4 book ai didi

php - 由于找不到 pdo_mysql 驱动程序导致 Yiic 迁移错误

转载 作者:行者123 更新时间:2023-11-29 06:42:23 24 4
gpt4 key购买 nike

我正在尝试学习 Yii,但我遇到了一个非常持久的错误,每当我使用 yiic 时,该错误就会出现。第一个系统详细信息:带有 apache2、php 5.5.3 和 mysql 5.5.3 的 Ubuntu 13.04。我运行/yiic migrate

在我正在开发的 webapp 的/protected 中。

我得到错误:

exception 'CDbException' with message 'CDbConnection failed to open the DB connection: could not find driver' in /var/www/yii/framework/db/CDbConnection.php:382

这似乎是因为在 CDbConnection.php 的第 382 行,脚本检查是否安装了 pod_mysql,但找不到它。

`if($this->_pdo===null)
{
if(empty($this->connectionString))
throw new CDbException('CDbConnection.connectionString cannot be empty.');
try
{
Yii::trace('Opening DB connection','system.db.CDbConnection');
$this->_pdo=$this->createPdoInstance();
$this->initConnection($this->_pdo);
$this->_active=true;
}
catch(PDOException $e)
{
if(YII_DEBUG)
{
throw new CDbException('CDbConnection failed to open the DB connection:'.

$e->getMessage(),(int)$e->getCode(),$e->errorInfo);

}
else
{
Yii::log($e->getMessage(),CLogger::LEVEL_ERROR,'exception.CDbException');

throw new CDbException('CDbConnection failed to open the DB connection.'

,(int)$e->getCode(),$e->errorInfo);
}
}
}

^^ 这是相关的代码片段。

运行结果

php -i|grep PDO gives 
PDO
PDO support => enabled
PDO drivers => sqlite
PDO Driver for SQLite 3.x => enabled

所以我的问题似乎是只有 sqlite 驱动程序在运行。但是,我已确保检查是否安装了 php-mysql(因为 pdo_mysql 已弃用并且在这个包中)。我已经想不出该做什么了,非常感谢您提供的所有帮助!

提前致谢!

最佳答案

控制台应用程序有自己的配置存储在 protected/config/console.php 中。请确保您已在那里配置了数据库组件。

关于php - 由于找不到 pdo_mysql 驱动程序导致 Yiic 迁移错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20692528/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com