Home » Database » DB » Bug #4539
cannot connect to Oracle with host/database
Details
| Request #4539 | cannot connect to Oracle with host/database |
|---|---|
| Submitted | 2005-06-06 16:05 UTC |
| From | antonomase at hotmail dot com |
| Status | Duplicate |
| Package | DB |
| PHP Version | 4.3.11 |
| OS | Windows server |
| Roadmaps | (Not assigned) |
Comments
[2005-06-06 16:05 UTC] antonomase at hotmail dot com
Description:
------------
It appears only when the Oracle database is on the same computer than PHP.
When you install OCI like described by Oracle, you can no more connect to the local database using the tnsnames.ora
eg : you cannot connect with
$c1 = ocilogon("scott", "tiger", "mydatabase");
but it's OK with
$c1 = ocilogon("scott", "tiger", "myserver/mydatabase");
With pear:db, you must use
$dbh = DB::connect("oci8://scott:tiger@myserver/mydatabase");
But in the oci8.php file, the $dsn['database'] is ignored and the connection fails.
So the right code is
$connect_function = $persistent ? 'OCIPLogon' : 'OCILogon';
if ($dsn['hostspec']) {
if ($dsn['database']) {
$this->connection = @$connect_function($dsn['username'],
$dsn['password'],
$dsn['hostspec'].'/'.$dsn['database']);
} else {
$this->connection = @$connect_function($dsn['username'],
$dsn['password'],
$dsn['hostspec']);
}
} elseif ($dsn['username'] || $dsn['password']) {
$this->connection = @$connect_function($dsn['username'],
$dsn['password']);
}