问题描述
尝试在 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 中找不到驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)