cvs: php4 /pear/DB oci8.php

From: Date: Sun, 06 Jan 2002 02:19:49 +0000
Subject: cvs: php4 /pear/DB oci8.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-1841@lists.php.net to get a copy of this message
cox Sat Jan 5 21:19:49 2002 EDT Modified files: /php4/pear/DB oci8.php Log: - change the case of column names to lower case when "optimize=portability" (use a slow php array_change_key_case() until PHP get its C native version avaible. Please do it!) - Improved error reporting in connection Index: php4/pear/DB/oci8.php diff -u php4/pear/DB/oci8.php:1.40 php4/pear/DB/oci8.php:1.41 --- php4/pear/DB/oci8.php:1.40 Thu Dec 27 06:46:46 2001 +++ php4/pear/DB/oci8.php Sat Jan 5 21:19:49 2002 @@ -17,7 +17,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: oci8.php,v 1.40 2001/12/27 11:46:46 cox Exp $ +// $Id: oci8.php,v 1.41 2002/01/06 02:19:49 cox Exp $ // // Database independent query interface definition for PHP's Oracle 8 // call-interface extension. @@ -85,9 +85,9 @@ */ function connect($dsninfo, $persistent = false) { - if (!DB::assertExtension("oci8")) + if (!DB::assertExtension('oci8')) { return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND); - + } $this->dsn = $dsninfo; $user = $dsninfo['username']; $pw = $dsninfo['password']; @@ -103,7 +103,10 @@ $conn = false; } if ($conn == false) { - return $this->raiseError(DB_ERROR_CONNECT_FAILED); + $error = OCIError(); + $error = (is_array($error)) ? $error['message'] : null; + return $this->raiseError(DB_ERROR_CONNECT_FAILED, null, null, + null, $error); } $this->connection = $conn; return DB_OK; @@ -227,6 +230,9 @@ } if ($fetchmode & DB_FETCHMODE_ASSOC) { $moredata = @OCIFetchInto($result,$arr,OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS); + if ($this->options['optimize'] == 'portability') { + $arr = array_change_key_case($arr, CASE_LOWER); + } } else { $moredata = @OCIFetchInto($result,$arr,OCI_RETURN_NULLS+OCI_RETURN_LOBS); } @@ -651,6 +657,18 @@ // }}} +} + +if (!function_exists('array_change_key_case')) { + define('CASE_UPPER', 1); + define('CASE_LOWER', 0); + function &array_change_key_case(&$array, $case) { + $casefunc = ($case == CASE_LOWER) ? 'strtolower' : 'strtoupper'; + foreach ($array as $key => $value) { + $return[$casefunc($key)] = $value; + } + return $return; + } } // Local variables:

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