Home » Database » DB » Bug #7501
ORACLE: connect method for PHP4 does not consider 'database' field in $dsn var
Details
| Submitted | 2006-04-27 09:46 UTC |
|---|---|
| From | dvdplm at gmail dot com |
| Assigned | aharvey |
| Status | Closed |
| Package | DB |
| PHP Version | 4.3.8 |
| OS | SuSE Linux 9.2 |
| Roadmaps | (Not assigned) |
Comments
[2006-04-27 09:46 UTC] dvdplm at gmail dot com
Description:
------------
There is a bug in the Oracle DB/oci8.php script, more precisely in the connect method.
The problem occurs when using PHP4 (4.3.8 in my case), and a dsn where both 'hostname' and 'database' keys are used. The solution is to move the "Backwards compatibility with DB < 1.7.0" (rows 229 - 234) stuff out from the PHP5 code so it's executed for either case (v4 and v5), and to modify the connection string construction accordingly for the v4 case (row 252).
In other words, DB/oci8.php does not use the "database" field of the $dsn array, but only the "hostspec" when using old style Oracle functions to connect to the database.
[Putting patch in here, as the test script is already 17 rows long - a patch upload field anyone? :-) ]
1: move rows 229 to 234 to row 218
2: edit row 254:
WAS: "$dsn['hostspec']);"
IS: "$db);"
Test script:
---------------
<?php
require "DB.php";
define("ORA_STRING","(DESCRIPTION=
(ADDRESS =
(PROTOCOL = TCP)
(HOST = 10.9.2.168)
(PORT = 1521)
)
(CONNECT_DATA = (SID = my_sid_str))
)");
define("DSN","oci8://my_usr:my_pwd@10.9.1.1:1521/".ORA_STRING);
$options=array('portability'=>DB_PORTABILITY_ALL);
$db =& DB::connect(DSN, $options);
var_dump($db);
?>
Expected result:
----------------
The var_dump is kind of verbose, but I see a "resource(11) of type (oci8 connection)" near the beginning when I use the patched version of oci8.php
Actual result:
--------------
"DB Error: connect failed"
...
[nativecode=ORA-12514: TNS:listener does not currently know of service requested in connect descriptor]