Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.5.0b4

Bug #4104 oci8://user:pwd@tnsname broken in php5
Submitted: 2005-04-08 15:00 UTC
From: adrian dot crossley at hesa dot ac dot uk Assigned: danielc
Status: Closed Package: MDB2_Driver_oci8
PHP Version: 5.0.3 OS: Windows 2000/2003
Roadmaps: (Not assigned)    
Subscription  


 [2005-04-08 15:00 UTC] adrian dot crossley at hesa dot ac dot uk
Description: ------------ With php4 I have always used a dns of oci8://user:pwd@tnsname to connect to my databases. This is broken in php5 because $dsn['database'] is passed to connect_function whereas in php4 it was $dsn['hostspec']. The php4 method was very much in keeping with normal Oracle connect strings. For php5 I have to use oci8://user:pwd@/tnsname. I can find no reason for this change. Am I really to change the syntax of all my dsn strings? Also, the php5 version attempts a "direct connect" (not sure what that is does it mean local?) when a No Listener error is encountered. In my case a failure to connect to my DEV2 database (its intentionally down) now causes php to connect to my LIVE (default) database. What is the reason for this too? The second isse compounds the first by causing all my dsn strings to connect to result in a connection to my LIVE (default) database. Bug #700 is similar. It notes "Dave makes some compelling points" but has unexplained Won't Fix status. Many thanks in advance Reproduce code: --------------- not applicable. Expected result: ---------------- not applicable. Actual result: -------------- not applicable.

Comments

 [2005-04-08 19:28 UTC] bretrzaun at hotmail dot com
Having the same problem here (PHP 5.0.4 on Windows XP).
 [2005-04-11 10:41 UTC] magnus at mek dot nu
I have this problem as well. And I installed DB-1.6.8 to have everything return to normal since this problem did not occur with php5 until I upgraded the pear class DB above 1.6.8... Cheers, Magnus
 [2005-04-11 15:12 UTC] danielc
The proper sysntax is to use oci8://user:pwd@/tnsname. A backawards compatibility hack has been added to the latest release (1.7.6).
 [2005-04-11 15:31 UTC] adrian dot crossley at hesa dot ac dot uk
Many thanks for the BC hack. Any news on the secondary issue. Why are we attempting to connect to an unnamed database when a TNS Listener is not found? In my opinion this should be handled at application level not library level.
 [2005-04-21 18:05 UTC] malists at epon dot ro
Couple enhancements and a bug report about oci8 in DB 1.7.5: 1. give preference to OCILogon (as it's recommended by Oracle and requires no configuration) rather than oci_connect if (function_exists('oci_connect')) { -> if (function_exists('ocilogon')) { 2. take in account the debug parameter and don't use @ in front of functions when it is > 2, as common.php does and others. 3. this is the correct OCILogon syntax: if ($dsn['hostspec']) { $this->connection = $connect_function($dsn['username'], $dsn['password'], '//' . $dsn['hostspec'] . '/' . $dsn['database']);
 [2006-01-13 00:03 UTC] izzyalanis at gmail dot com
Also needs to support tnsnames-less connections with full hostname and port specified. "username:password@host:port/service" should be executed as... OCILogin("username", "password", "host:port:service"); "username:password@host/service" should be executed as... OCILogin("username", "password", "host/service") or OCILogin("username", "password", "host:1521/service") "username:password@service" should be executed as... OCILogin("username", "password", "service") and "username:password@/service" should also be executed as... OCILogin("username", "password", "service")
 [2006-01-13 09:35 UTC] lsmith
Just place whatever string you want used into the "hostspec" and be done with it .. the oci8 driver does not attempt to assemble together the database identifier from multiple settings. As for not silencing native calls when debug is enabled. This is not really feasible, as this would add countless if statements all over the place. The most efficient solution is to register your own error handler in that case, since the error handler is notified even for silenced errors.
 [2006-01-17 15:09 UTC] izzyalanis at gmail dot com
When the dsn is passed to DB::connect as a string, rather than an associative array, it's automagically picked apart into the individual pieces: 'hostspec', 'port', and 'database' (etc). Of course, one could avoid passing the dsn as a string, and always pass it as an associative array, with 'the right' string in the hostpec (or database) slot as a workaround... but getting the code to work right would be nice. And not really all that difficult.
 [2006-03-01 23:44 UTC] lsmith
So do you have a patch ready?
 [2006-03-12 17:45 UTC] lsmith
#4539 and #6925 provide some additional infos/aspects
 [2006-05-09 09:23 UTC] lsmith (Lukas Smith)
All new features should go into MDB2 .. we can always see about backporting ..
 [2006-05-10 18:55 UTC] gmandas at scholastic dot com (Greg Mandas)
PHP5 on Solaris 11 Oracle9i. I can't get connect to connect...
 [2006-05-10 19:17 UTC] gmandas at scholastic dot com (Greg mandas)
Please disregard my previous posting. I was able to connect using: $dsn = 'oci8://user:pass@[IP ADDRESS]:1521/(DESCRIPTION = (ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = [DNS NAME] )(PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = oracle)))';
 [2006-05-12 07:46 UTC] lsmith (Lukas Smith)
How about the following code: <?php require 'MDB2.php'; $dsnarr[] = "oci8://username:password@host:port/service"; $dsnarr[] = "oci8://username:password@host/service"; $dsnarr[] = "oci8://username:password@service"; $dsnarr[] = "oci8://username:password@/service"; $dsnarr[] = 'oci8://user:pass@host:port/(DESCRIPTION = (ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = [DNS NAME] )(PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = oracle)))'; foreach ($dsnarr as $dsn) { var_dump($dsn); $dsn = MDB2::parseDSN($dsn); $sid = ''; if (isset($dsn['hostspec']) && $dsn['hostspec']) { $sid = $dsn['hostspec']; $port = $service = ''; if (isset($dsn['database']) && $dsn['database']) { if (isset($dsn['port']) && $dsn['port']) { $port = ':'.$dsn['port']; } $service = $dsn['database']; if (substr($service, 0, 1) !== '/') { $service = '/'.$service; } $sid = '//'.$sid.$port.$service; } } elseif (isset($dsn['database']) && $dsn['database']) { $sid = $dsn['database']; } else { $sid = getenv('ORACLE_SID'); } var_dump($dsn); var_dump($sid); }
 [2006-05-13 16:00 UTC] lsmith (Lukas Smith)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.