cvs: pear /MDB2/MDB2/Driver oci8.php

From: Date: Wed, 07 Feb 2007 09:59:33 +0000
Subject: cvs: pear /MDB2/MDB2/Driver oci8.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-44571@lists.php.net to get a copy of this message
quipo Wed Feb 7 09:59:33 2007 UTC Modified files: /pear/MDB2/MDB2/Driver oci8.php Log: DSN handling improvements (req #10018) http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/oci8.php?r1=1.189&r2=1.190&diff_format=u Index: pear/MDB2/MDB2/Driver/oci8.php diff -u pear/MDB2/MDB2/Driver/oci8.php:1.189 pear/MDB2/MDB2/Driver/oci8.php:1.190 --- pear/MDB2/MDB2/Driver/oci8.php:1.189 Sat Feb 3 23:54:46 2007 +++ pear/MDB2/MDB2/Driver/oci8.php Wed Feb 7 09:59:32 2007 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ -// $Id: oci8.php,v 1.189 2007/02/03 23:54:46 quipo Exp $ +// $Id: oci8.php,v 1.190 2007/02/07 09:59:32 quipo Exp $ /** * MDB2 OCI8 driver @@ -323,6 +323,7 @@ } $sid = ''; + /* if ($this->dsn['hostspec']) { $sid = $this->dsn['hostspec']; if (!$this->options['emulate_database'] && $this->database_name) { @@ -346,6 +347,37 @@ return $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null, 'it was not specified a valid Oracle Service Identifier (SID)', __FUNCTION__); } + */ + if (!empty($this->dsn['service']) && $this->dsn['hostspec']) { + //oci8://username:password@foo.example.com[:port]/?service=service + // service name is given, it is assumed that hostspec is really a + // hostname, we try to construct an oracle connection string from this + $port = $this->dsn['port'] ? $this->dsn['port'] : 1521; + $sid = sprintf("(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP) + (HOST=%s) (PORT=%s))) + (CONNECT_DATA=(SERVICE_NAME=%s)))", + $this->dsn['hostspec'], + $port, + $this->dsn['service'] + ); + } elseif ($this->dsn['hostspec']) { + // we are given something like 'oci8://username:password@foo/' + // we have hostspec but not a service name, now we assume that + // hostspec is a tnsname defined in tnsnames.ora + $sid = $this->dsn['hostspec']; + } else { + // oci://username:password@ + // if everything fails, we have to rely on environment variables + if (getenv('ORACLE_SID')) { + $sid = getenv('ORACLE_SID'); + } elseif ($sid = getenv('TWO_TASK')) { + $sid = getenv('TWO_TASK'); + } else { + return $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null, + 'not a valid connection string or environment variable [ORACLE_SID|TWO_TASK] not set', + __FUNCTION__); + } + } if (function_exists('oci_connect')) { if (isset($this->dsn['new_link'])

« previous php.pear.cvs (#44571) next »