0

我已经在我的机器上成功安装了 YII 框架,并使用 YII 的终端命令创建了一个新的应用程序。

YiiRoot/framework/yiic webapp helloworld

在我的 Web 服务器上创建了名为 helloworld 的目录。从那里我将数据库连接从 SQLlite 更改为 MySql。

'db'=>array(
        'connectionString' => 'mysqli:host=localhost;dbname=yii_amar',
        'emulatePrepare' => true,
        'username' => 'root',
        'password' => 'redhat456',
        'charset' => 'utf8',
        'tablePrefix' => '',
    ), 

当我使用命令在我的 YII 终端中测试数据库连接时。

protected/yiic shell

然后使用此命令测试数据库连接。

echo Yii::app()->db->connectionString;

它给了我错误。

exception 'CDbException' with message 'CDbConnection failed to open the DB connection: could not find driver' in /root/Desktop/htdocs/ayii/framework/db/CDbConnection.php:381 

谁可以帮我这个事。

4

1 回答 1

1

替换这个

'connectionString' => 'mysqli:host=localhost;dbname=yii_amar'

有了这个

'connectionString' => 'mysql:host=localhost;dbname=yii_amar'

dsn应该以mysql.

“找不到驱动程序”来自PDO。检查pdo_mysql扩展是否通过phpinfo.

于 2013-06-05T14:15:16.823 回答