Page 1 of 1
Problem with Oracle PDO connectivity
#1
Posted 16 December 2009 - 12:06 PM
Hi all:
I'm new to PHP and frameworks so perhaps what I'm doing is wrong and I can't tell but here it goes...
Environment:
* Oracle 10g (10.2.0.4) under Windows Server 2003 SP2
* Oracle Apache server 1.3
* PHP 5.2.11 for Windows
* Yii 1.1rc.r1585
Background:
Apache wouldn't load the php_pdo_oci.dll extension from PHP 5.2.11 but the PHP CLI did load it. With it, yiic would allow the creation of models and cruds but since Apache didn't recognize it, whenever I tried to access the list.php page for the model I would get a "driver not found" error. I downgraded to the dll from EasyPHP 2.0b (PHP 5.0?) as both Apache and the CLI seem to recognize it.
The problem:
If I write a simple page with the following statement:
$conn = new PDO('oci:dbname=mydb', 'myusername', 'mypassword');
it executes fine with no errors. However, when setting up the Yii connection in protected\config\main.php as follows:
'db'=>array(
'class'=>'CDbConnection',
'connectionString'=>'oci:mydb',
'username'=>'myusername',
'password'=>'mypassword',
and then attempt to create a model using yiic I get the following error message:
exception 'CDbException' with message 'CDbConnection failed to open the DB conne
ction: SQLSTATE[HY000]: pdo_oci_handle_factory: ORA-12560: TNS:protocol adapter
error ext\pdo_oci\oci_driver.c:579)' in I:\WEB\yii\framework\db\CDbConnection.php:262
I have also tried the long connectionString 'oci://servername:1521/mydb' to no avail.
The question is, do I have a .dll problem, a syntax problem or is it a Yii bug? Any help will be greatly appreciated.
Regards,
José
I'm new to PHP and frameworks so perhaps what I'm doing is wrong and I can't tell but here it goes...
Environment:
* Oracle 10g (10.2.0.4) under Windows Server 2003 SP2
* Oracle Apache server 1.3
* PHP 5.2.11 for Windows
* Yii 1.1rc.r1585
Background:
Apache wouldn't load the php_pdo_oci.dll extension from PHP 5.2.11 but the PHP CLI did load it. With it, yiic would allow the creation of models and cruds but since Apache didn't recognize it, whenever I tried to access the list.php page for the model I would get a "driver not found" error. I downgraded to the dll from EasyPHP 2.0b (PHP 5.0?) as both Apache and the CLI seem to recognize it.
The problem:
If I write a simple page with the following statement:
$conn = new PDO('oci:dbname=mydb', 'myusername', 'mypassword');
it executes fine with no errors. However, when setting up the Yii connection in protected\config\main.php as follows:
'db'=>array(
'class'=>'CDbConnection',
'connectionString'=>'oci:mydb',
'username'=>'myusername',
'password'=>'mypassword',
and then attempt to create a model using yiic I get the following error message:
exception 'CDbException' with message 'CDbConnection failed to open the DB conne
ction: SQLSTATE[HY000]: pdo_oci_handle_factory: ORA-12560: TNS:protocol adapter
error ext\pdo_oci\oci_driver.c:579)' in I:\WEB\yii\framework\db\CDbConnection.php:262
I have also tried the long connectionString 'oci://servername:1521/mydb' to no avail.
The question is, do I have a .dll problem, a syntax problem or is it a Yii bug? Any help will be greatly appreciated.
Regards,
José
José
#3
Posted 29 December 2009 - 02:56 PM
The same above and certify yourself that you are using Oracle CLIENT 10+ version (install OracleXE on your dev machine and it shoul work properly).
Oracle Client 9 and PHP 5.2 doesn't work well together on Windows.
Oracle Client 9 and PHP 5.2 doesn't work well together on Windows.
Yii::app()->user->setFlash('message', 'Yii is AWESOME! =D ');
#4
Posted 29 December 2009 - 06:46 PM
Hi:
Thanks for your replies. I kept working at it until (it seems) I found the right combination about a week ago:
php.ini:
extension=php_oci8.dll
extension=php_pdo_oci.dll
plus... (and this completed the trick):
main.php:
'connectionString'=>'oci:dbname=mydb',
It looks like 'connectionString'=>'oci:' (Oracle version) requires 'dbname='. It has been working fine since I made the change. If it's not that explicit it won't work. Thanks again.
Regards,
Jose
Thanks for your replies. I kept working at it until (it seems) I found the right combination about a week ago:
php.ini:
extension=php_oci8.dll
extension=php_pdo_oci.dll
plus... (and this completed the trick):
main.php:
'connectionString'=>'oci:dbname=mydb',
It looks like 'connectionString'=>'oci:' (Oracle version) requires 'dbname='. It has been working fine since I made the change. If it's not that explicit it won't work. Thanks again.
Regards,
Jose
José
#6
Posted 12 May 2010 - 05:11 PM
Have a similar problem...
can connect to my oracle db using codeigniter but have trouble using shell command in Yii. Gives me the fallowing error:
my main.php looks like this:
When I change connectionString dbname=XE
When I got rid of "'charset' => 'utf8'," line, I get this error
Line 158 of ModelCommand.php is:
and it lead me to the COociShema.php file, but it looks like it should
any clue what might be wrong? (I have "cities" table in my oracle db)
can connect to my oracle db using codeigniter but have trouble using shell command in Yii. Gives me the fallowing error:
>> model cities exception 'CDbException' with message 'CDbConnection failed to open the DB conne ction: SQLSTATE[42S02]: pdo_oci_handle_factory: ORA-12154: TNS:could not resolve the connect identifier specified (ext\pdo_oci\oci_driver.c:579)' in C:\wamp\www\yii-1.1.2\framework\db\CDbConnection.php:267
my main.php looks like this:
'connectionString' => 'oci:host=localhost/XE;dbname=""', // Tried both connectionStrings //'connectionString'=>'oci:dbname=mydb', //'connectionString' => 'oci:host=localhost/XE;dbname=mydb', 'emulatePrepare' => true, 'username' => '***', 'password' => '***', 'charset' => 'utf8',
When I change connectionString dbname=XE
>> model cities exception 'CDbException' with message 'CDbConnection failed to open the DB conne ction: SQLSTATE[HY000]: General error: 922 OCIStmtExecute: ORA-00922: missing or invalid option (ext\pdo_oci\oci_driver.c:341)' in C:\wamp\www\yii-1.1.2\frame work\db\CDbConnection.php:267
When I got rid of "'charset' => 'utf8'," line, I get this error
Warning: Invalid argument supplied for foreach() in C:\wamp\www\yii-1.1.2\framework\cli\commands\shell\ModelCommand.php on line 158 Warning: the table 'cities' does not exist in the database.
Line 158 of ModelCommand.php is:
foreach ($table->foreignKeys as $fkName => $fkEntry)
and it lead me to the COociShema.php file, but it looks like it should
if($schema===$this->getDefaultSchema()) $names[]=$row['TABLE_NAME']; else $names[]=$row['SCHEMA_NAME'].'.'.$row['TABLE_NAME'];
any clue what might be wrong? (I have "cities" table in my oracle db)
#8
Posted 14 May 2010 - 07:51 AM
I get the error
Does that mean that the connection is established? or how can I check?
Warning: Invalid argument supplied for foreach() in C:\wamp\www\yii-1.1.2\framework\cli\commands\shell\ModelCommand.php on line 158 Warning: the table 'cities' does not exist in the database.
Does that mean that the connection is established? or how can I check?
Page 1 of 1

Sign In
Register
Help


MultiQuote