PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » MDB2_Driver_oci8 » Bug #4104

oci8://user:pwd@tnsname broken in php5

Details

Submitted2005-04-08 15:00 UTC
Fromadrian dot crossley at hesa dot ac dot uk
Assigneddanielc
StatusClosed
PackageMDB2_Driver_oci8
PHP Version5.0.3
OSWindows 2000/2003
Roadmaps(Not assigned)

Comments

[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.

[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: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-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-05-10 18:55 UTC] gmandas at scholastic dot com

PHP5 on Solaris 11 Oracle9i. I can't get connect to connect...

[2006-05-10 19:17 UTC] gmandas at scholastic dot com

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)))';