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

From: Date: Thu, 25 Nov 2004 23:34:45 +0000
Subject: cvs: pear /MDB2/MDB2/Driver oci8.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-26504@lists.php.net to get a copy of this message
lsmith Thu Nov 25 18:34:45 2004 EDT Modified files: /pear/MDB2/MDB2/Driver oci8.php Log: - use php5 function to connect if available http://cvs.php.net/diff.php/pear/MDB2/MDB2/Driver/oci8.php?r1=1.48&r2=1.49&ty=u Index: pear/MDB2/MDB2/Driver/oci8.php diff -u pear/MDB2/MDB2/Driver/oci8.php:1.48 pear/MDB2/MDB2/Driver/oci8.php:1.49 --- pear/MDB2/MDB2/Driver/oci8.php:1.48 Thu Nov 25 17:18:11 2004 +++ pear/MDB2/MDB2/Driver/oci8.php Thu Nov 25 18:34:45 2004 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@backendmedia.com> | // +----------------------------------------------------------------------+ -// $Id: oci8.php,v 1.48 2004/11/25 22:18:11 lsmith Exp $ +// $Id: oci8.php,v 1.49 2004/11/25 23:34:45 lsmith Exp $ /** * MDB2 OCI8 driver @@ -253,11 +253,23 @@ putenv('ORACLE_HOME='.$this->options['home']); } putenv('ORACLE_SID='.$sid); - $function = ($persistent ? 'OCIPLogon' : 'OCINLogon'); - $connection = @$function($username, $password, $sid); + + if (version_compare(phpversion(), '5.0.0', '>=')) { + $connection = oci_new_connect($username, $password, $sid); + $error = OCIError(); + if (!empty($error) && $error['code'] == 12541) { + // Couldn't find TNS listener. Try direct connection. + $connection = oci_new_connect($username, $password); + } + } else { + $function = $persistent ? 'OCIPLogon' : 'OCILogon'; + $connection = @$function($username, $password, $sid); + } + if (!$connection) { - $connection = $this->raiseError(MDB2_ERROR_CONNECT_FAILED); + return $this->raiseError(MDB2_ERROR_CONNECT_FAILED); } + return $connection; }

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