CDbConnection无法打开数据库连接:在Yii中找不到驱动程序 [英] CDbConnection failed to open the DB connection: could not find driver in 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
我该如何解决?
推荐答案
您应检查的内容
首先,您应该检查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 dlls
check you ext folder in php contains pdo_mysql dlls
有时会由于安装zend服务器而出现问题.您应该使用php扩展名检查zend服务器是否正确
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屋!