Yii连接oracle数据库,报错 [ 新手入门 ]
Yii连接oracle 11g r2数据库,报错。
main.php
'connectionString' =>'oci:dbname=172.30.1.39:1521/orcl',
'username' => 'root',
'password' => 'a'
),
CDbException
CDbConnection 无法开启数据库连线: SQLSTATE[]: pdo_oci_handle_factory: <<Unknown>> (ext\pdo_oci\oci_driver.c:579)
D:\skill\finance\yii-1.1.10.r3566\framework\db\CDbConnection.php(382)
370 throw new CDbException(Yii::t('yii','CDbConnection.connectionString cannot be empty.'));
371 try
372 {
373 Yii::trace('Opening DB connection','system.db.CDbConnection');
374 $this->_pdo=$this->createPdoInstance();
375 $this->initConnection($this->_pdo);
376 $this->_active=true;
377 }
378 catch(PDOException $e)
379 {
380 if(YII_DEBUG)
381 {
382 throw new CDbException(Yii::t('yii','CDbConnection failed to open the DB connection: {error}',
383 array('{error}'=>$e->getMessage())),(int)$e->getCode(),$e->errorInfo);
384 }
385 else
386 {
387 Yii::log($e->getMessage(),CLogger::LEVEL_ERROR,'exception.CDbException');
388 throw new CDbException(Yii::t('yii','CDbConnection failed to open the DB connection.'),(int)$e->getCode(),$e->errorInfo);
389 }
390 }
391 }
392 }
393
394 /**
Stack Trace
#0 +– D:\skill\finance\yii-1.1.10.r3566\framework\db\CDbConnection.php(331): CDbConnection->open()
请问这是什么原因呢?
共 4 条回复
-
改成
'db'=>array( 'class'=>'CDbConnection', 'connectionString' => 'oci:dbname=172.30.1.39:1521/orcl;charset=utf8', 'emulatePrepare' => true, 'username' => 'imp', 'password' => 'aa' ),
错误提示:
CDbConnection 无法开启数据库连线: SQLSTATE[HY000]: OCIEnvNlsCreate: Check the character set is valid and that PHP has access to Oracle libraries and NLS data (ext\pdo_oci\oci_driver.c:558) D:\skill\finance\yii-1.1.10.r3566\framework\db\CDbConnection.php(382) 370 throw new CDbException(Yii::t('yii','CDbConnection.connectionString cannot be empty.')); 371 try 372 { 373 Yii::trace('Opening DB connection','system.db.CDbConnection'); 374 $this->_pdo=$this->createPdoInstance(); 375 $this->initConnection($this->_pdo); 376 $this->_active=true; 377 } 378 catch(PDOException $e) 379 { 380 if(YII_DEBUG) 381 { 382 throw new CDbException(Yii::t('yii','CDbConnection failed to open the DB connection: {error}',
-
yk19880829 回复于 2012-07-11 18:47 举报
连接ORACLE 有3种方式 THIN JDBC 和 OCI方式 PHP连接ORACLE是以OCI连接的
首先要开启PHP.INI里相关
extension=php_pdo_oci.dll
extension=php_pdo_oci8.dll
这2个扩展 然后要确保你的PHP目录下有此DLL文件!
onunix china
注册时间:2012-03-19
最后登录:1970-01-01
在线时长:0小时0分
最后登录:1970-01-01
在线时长:0小时0分
- 粉丝2
- 金钱1145
- 威望0
- 积分1145