CDbConnection 打开数据库连接失败:在 Yii 中找不到驱动程序 [英] CDbConnection failed to open the DB connection: could not find driver in Yii

查看:44
本文介绍了CDbConnection 打开数据库连接失败:在 Yii 中找不到驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在 yii 框架中连接 mysql 时,它显示

while trying to connect with mysql in yii framework it shows

CDbConnection 无法打开数据库连接:找不到驱动程序"错误

"CDbConnection failed to open the DB connection: could not find driver " error

php 代码:

     'db'=>array(
        'class' => 'CDbConnection',
        'connectionString' => 'mysql:host=localhost:3306;dbname=testdrive',
        'emulatePrepare' => true,
        'username' => 'root',
        'password' => 'root',
        'charset' => 'utf8',
    ), 

我的 php 驱动程序已经启用,但它显示相同的错误

my php drivers are already enabled , but it shows the same error

我正在使用 zend studio,为此使用 zend 服务器

Im using zend studio, zend server for this

我该如何解决这个问题?

how could i fix this?

推荐答案

你应该检查的事情

首先你应该检查 phpinfo() 是否安装了 pdo_drivers.

First you should check phpinfo() for the pdo_drivers installed.

如果你使用 IIS 服务器,你应该检查是否安装了 php 扩展.

if u use IIS server , you should check php extensions installed or not.

检查 php.ini 是否正确给出了 extensions_dir

check php.ini for extensions_dir is properly given

检查 php 中的 ext 文件夹是否包含 pdo_mysql dll

check you ext folder in php contains pdo_mysql dlls

有时可能是由于安装了 zend 服务器而出现问题.您应该检查 zend 服务器是否正确使用了 php 扩展

Some times the problem may occur due to zend server installation .You should check zend server is properly using the php extensions

之后使用以下函数检查简单的php-mysql连接

After that check simple php-mysql connection using the following functions

mysql_connect('localhost:3306','root','root');
mysql_select_db('testdrive');

如果可行,则使用 Yii、Slim、Zend php-mysql 连接

If it works then go with Yii, Slim, Zend php-mysql connections

这篇关于CDbConnection 打开数据库连接失败:在 Yii 中找不到驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆