php探针显示支持mysql数据库,并且我在php探针测试链接数据库成功
但是yii的requirements测试却显示不支持mysql数据库
请问怎么回事呢?
http://******/ (已删除)
php探针显示支持mysql数据库,并且我在php探针测试链接数据库成功
但是yii的requirements测试却显示不支持mysql数据库
请问怎么回事呢?
http://******/ (已删除)
Yii要求的是PDO Mysql驱动。你可以用phpinfo()看看。
嗯,是服务器的问题
现在安装了pdo_mysql,但还是不行
Quote
描述
CDbConnection 无法开启数据库连线: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 1
源文件
/data0/htdocs/blog/framework/db/CDbConnection.php(248)
00236: {
00237: if(empty($this->connectionString))
00238: throw new CDbException(Yii::t('yii','CDbConnection.connectionString cannot be empty.'));
00239: try
00240: {
00241: Yii::trace('Opening DB connection','system.db.CDbConnection');
00242: $this->_pdo=$this->createPdoInstance();
00243: $this->initConnection($this->_pdo);
00244: $this->_active=true;
00245: }
00246: catch(PDOException $e)
00247: {
00248: throw new CDbException(Yii::t('yii','CDbConnection failed to open the DB connection: {error}',
00249: array('{error}'=>$e->getMessage())));
00250: }
00251: }
00252: }
00253:
00254: /**
00255: * Closes the currently active DB connection.
00256: * It does nothing if the connection is already closed.
00257: */
00258: protected function close()
00259: {
00260: Yii::trace('Closing DB connection','system.db.CDbConnection');
堆栈追踪
#0 /data0/htdocs/blog/framework/db/CDbConnection.php(223): CDbConnection->open()
#1 /data0/htdocs/blog/framework/db/CDbConnection.php(202): CDbConnection->setActive(true)
#2 /data0/htdocs/blog/framework/base/CModule.php(353): CDbConnection->init()
#3 /data0/htdocs/blog/framework/base/CApplication.php(338): CModule->getComponent('db')
#4 /data0/htdocs/blog/framework/db/ar/CActiveRecord.php(835): CApplication->getDb()
#5 /data0/htdocs/blog/framework/db/ar/CActiveRecord.php(2136): CActiveRecord->getDbConnection()
#6 /data0/htdocs/blog/framework/db/ar/CActiveRecord.php(634): CActiveRecordMetaData->__construct(Object(Article))
#7 /data0/htdocs/blog/protected/models/Article.php(12): CActiveRecord::model('Article')
#8 /data0/htdocs/blog/protected/views/site/index.php(13): Article::model()
#9 /data0/htdocs/blog/framework/web/CBaseController.php(119): require('/data0/htdocs/b…')
#10 /data0/htdocs/blog/framework/web/CBaseController.php(88): CBaseController->renderInternal('/data0/htdocs/b…', NULL, true)
#11 /data0/htdocs/blog/framework/web/CController.php(701): CBaseController->renderFile('/data0/htdocs/b…', NULL, true)
#12 /data0/htdocs/blog/framework/web/CController.php(640): CController->renderPartial('index', NULL, true)
#13 /data0/htdocs/blog/protected/controllers/SiteController.php(35): CController->render('index')
#14 /data0/htdocs/blog/framework/web/actions/CInlineAction.php(32): SiteController->actionIndex()
#15 /data0/htdocs/blog/framework/web/CController.php(300): CInlineAction->run()
#16 /data0/htdocs/blog/framework/web/CController.php(278): CController->runAction(Object(CInlineAction))
#17 /data0/htdocs/blog/framework/web/CController.php(257): CController->runActionWithFilters(Object(CInlineAction), Array)
#18 /data0/htdocs/blog/framework/web/CWebApplication.php(332): CController->run('')
#19 /data0/htdocs/blog/framework/web/CWebApplication.php(120): CWebApplication->runController('')
#20 /data0/htdocs/blog/framework/base/CApplication.php(133): CWebApplication->processRequest()
#21 /data0/htdocs/blog/index.php(12): CApplication->run()
#22 {main}
你的app config是怎样的?设置'emulatePrepare'=>true ?
app config 是:
Quote
// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');
// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'xxxx网',
'defaultController'=>'site',
// preloading 'log' component
'preload'=>array('log'),
// autoloading model and component classes
'import'=>array(
'application.models.*',
'application.components.*',
'application.helpers.*',
),
'language'=>'zh_cn',
// application components
'components'=>array(
//'cache'=>array('class'=>'CDbCache','connectionID'=>'db'),
'cache'=>array('class'=>'CMemCache'),
//'cache'=>array('class'=>'CDummyCache'),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning',
),
array(
'class'=>'CWebLogRoute',
'levels'=>'trace',
),
),
),
'image'=>array(
'class'=>'application.extensions.image.CImageComponent',
// GD or ImageMagick
'driver'=>'GD',
// ImageMagick setup path
//'params'=>array('directory'=>'/opt/local/bin'),
),
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
),
// uncomment the following to set up database
'db'=>array(
'class'=>'CDbConnection',
'connectionString'=>'mysql:host=localhost;dbname=xxxx',
'username'=>'xxx',
'password'=>'xxxxxxx',
'charset'=>'utf8',
'schemaCachingDuration'=>864000,
'enableParamLogging'=>true,
),
'authManager'=>array(
'class'=>'CDbAuthManager',
'connectionID'=>'db',
),
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'rules'=>array(
'/<categorypath:.*>/<id:\d+>_<page:\d+>.html' => 'article/show',
'/<categorypath:.*>/<id:\d+>.html' => 'article/show',
'/list/<typeid:\d+>/<page:\d+>' => 'article/list',
'/list/<typeid:\d+>' => 'article/list',
'/list' => 'article/list',
'/search' => 'article/list',
'/search/' => 'article/list',
'/index.html' => 'site/index',
),
),
'ys'=>array(
'class'=>'application.extensions.ys.ys',
),
),
// application-level parameters that can be accessed
// using Yii::app()->params['paramName']
'params'=>array(
// this is used in contact page
'adminEmail'=>'test@21cn.com',
),
);
在'db'里加上'emulatePrepare'=>true
多谢强,现在数据库可以连接了