PEAR is archived and read-only

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

Home » Database » MDB2 » Bug #4854

Oracle Easy Connect syntax only works with array DSN

Details

Submitted2005-07-19 05:26 UTC
Fromcjbj at hotmail dot com
Assignedquipo
StatusClosed
PackageMDB2
PHP Version5.0.4
OSLinux x86
Roadmaps(Not assigned)

Comments

[2005-07-19 05:26 UTC] cjbj at hotmail dot com

Description:
------------
Oracle's "Easy Connect" syntax works with MDB2's
array DSN, but not the string form.

To use Easy Connect, Oracle 10g client libs are required.
The Easy Connect syntax is

username/password@[//]host[:port][/service_name]

e.g.

sqlplus scott/tiger@//mymachine:1521/orcl

Reproduce code:
---------------
require_once 'MDB2.php';

// This works
$dsn = array(
'phptype' => 'oci8',
'hostspec' => '//mymachine/orcl',
'username' => 'scott',
'password' => 'tiger',
);

// This doesn't connect
$dsn = 'oci8://scott:tiger@//mymachine/oracle';

$db = MDB2::connect($dsn);

Expected result:
----------------
Successful connection

Actual result:
--------------
The connection fails and $db->getDebugInfo() gives:

[Error message: it was not specified a valid Oracle Service Identifier (SID)] ** oci8:///frodo/oracle:xxx@//frodo/oracle

[2005-07-19 05:32 UTC] cjbj at hotmail dot com

The service name typo in my example is not the cause of the
problem. Even with "orcl" in the failure-case example, the
connection does not succeed.

[2005-08-09 14:33 UTC] david dot coallier at gmail dot com

What if you try this:

$dsn = array(
'phptype' => 'oci8',
'hostspec' => 'hostname',
'username' => 'scott',
'password' => 'tiger',
'database' => 'orcacle',
);

[2005-08-13 16:00 UTC] davidc at phpsec dot org

Please reply, I will close this issue in 3 days.

Thank you
David

[2006-12-18 23:37 UTC] cjbj at hotmail dot com

This bug still exists. The DSN parsing overwrites the username.

Looking in _doConnect() in Driver/oci8.php, the DSNs

oci8://hr:hr@localhost/XE

and

$dsn = array(
'phptype' => 'oci8',
'hostspec' => 'hostname',
'username' => 'scott',
'password' => 'tiger',
'database' => 'XE',
);

were previously both parsed with username set to XE, hostspec set to
localhost and database set to false.

(BTW, protocol is set to "tcp" with the former but not the latter
code)

Workaround: This array DSN connects correctly:

$dsn = array(
'phptype' => 'oci8',
'username' => 'hr',
'password' => 'hr',
'hostspec' => '//localhost/XE'
);