cvs: php4 /pear/DB oci8.php
| From: | Thomas V.V.Cox | Date: | Thu, 29 Nov 2001 18:46:34 +0000 |
| Subject: | cvs: php4 /pear/DB oci8.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-1431@lists.php.net to get a copy of this message | ||
cox Thu Nov 29 13:46:34 2001 EDT
Modified files:
/php4/pear/DB oci8.php
Log:
patch to support columns from functions without alias
Index: php4/pear/DB/oci8.php
diff -u php4/pear/DB/oci8.php:1.36 php4/pear/DB/oci8.php:1.37
--- php4/pear/DB/oci8.php:1.36 Tue Nov 6 12:15:32 2001
+++ php4/pear/DB/oci8.php Thu Nov 29 13:46:34 2001
@@ -17,7 +17,7 @@
// | |
// +----------------------------------------------------------------------+
//
-// $Id: oci8.php,v 1.36 2001/11/06 17:15:32 cox Exp $
+// $Id: oci8.php,v 1.37 2001/11/29 18:46:34 cox Exp $
//
// Database independent query interface definition for PHP's Oracle 8
// call-interface extension.
@@ -535,12 +535,12 @@
// Field parsing: Try to find final column names
$fa = array();
$grab = true;
+ $is_function = false;
$tmpbuff = '';
for ($i = 0; $i < strlen($f); $i++) {
- // Probably doesn't work if the query contains a funcion without
- // alias ("AS"), for ex: to_char(...) as date
if ($f{$i} == '(') { //don't parse commas acting as func params
$grab = false;
+ $is_function = true;
} elseif ($f{$i} == ')') {
$grab = true;
}
@@ -548,12 +548,21 @@
$tmpbuff = '';
}
if ($f{$i} == ',' && $grab) {
+ if ($is_function) {
+ // Oracle names function cols without alias as they are:
+ // count(foo) will be converted to column "COUNT(FOO)"
+ $tmpbuff = '"' . strtoupper($tmpbuff) . '"';
+ $is_function = false;
+ }
$fa[] = $tmpbuff;
$tmpbuff = '';
continue;
}
$tmpbuff .= $f{$i};
}
+ if ($is_function) {
+ $tmpbuff = '"' . strtoupper($tmpbuff) . '"';
+ }
$fa[] = $tmpbuff;
$fields = implode(', ', $fa);
@@ -563,9 +572,7 @@
" (SELECT rownum as linenum, $fields FROM".
" ($query)".
" ) ".
- "WHERE linenum BETWEEN $from AND ". ($from + $count) .
- "$orderby";
-
+ "WHERE linenum BETWEEN $from AND ". ($from + $count) . $orderby;
return $query;
}