Date: 12/16/99
- Next message: Michael Haertl: "[PHPLIB-DEV] Some ideas on tpl_form"
- Previous message: kir: "[PHPLIB-DEV] cvs commit"
- Next in thread: kir: "[PHPLIB-DEV] cvs commit"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
From: kir
Date: Thu Dec 16 13:07:46 1999
Modified files:
php-lib/CHANGES
php-lib/php/db_oracle.inc
Log message:
Changed num_rows function in db_oracle.inc
Index: php-lib/CHANGES
diff -u php-lib/CHANGES:1.153 php-lib/CHANGES:1.154
--- php-lib/CHANGES:1.153 Wed Dec 15 11:54:49 1999
+++ php-lib/CHANGES Thu Dec 16 13:07:14 1999
@@ -1,4 +1,8 @@
-$Id: CHANGES,v 1.153 1999/12/15 10:54:49 kir Exp $
+$Id: CHANGES,v 1.154 1999/12/16 12:07:14 kir Exp $
+
+16-Dec-1999 kir
+ - Changed num_rows() function in db_oracle.inc. Now it works for all?
+ cases, or at least should work.
15-Dec-1999 kir
- Modelled ct_oracle.inc after ct_mysql.inc and ct_split_sql.inc
Index: php-lib/php/db_oracle.inc
diff -u php-lib/php/db_oracle.inc:1.21 php-lib/php/db_oracle.inc:1.22
--- php-lib/php/db_oracle.inc:1.21 Wed Dec 15 11:54:49 1999
+++ php-lib/php/db_oracle.inc Thu Dec 16 13:07:15 1999
@@ -4,7 +4,7 @@
*
* Copyright (c) 1998,1999 Luis Francisco Gonzalez Hernandez
*
- * $Id: db_oracle.inc,v 1.21 1999/12/15 10:54:49 kir Exp $
+ * $Id: db_oracle.inc,v 1.22 1999/12/16 12:07:15 kir Exp $
*
*/
@@ -357,19 +357,25 @@
## this is the important part and it is also the HACK!
if (eregi("^[[:space:]]*SELECT[[:space:]]",$this->lastQuery) ) {
+
+ # This works for all?? cases, including SELECT DISTINCT case.
+ # We just make select count(*) from original sql expression
+ # and remove ORDER BY (if any) for speed
+ # I like regular expressions too ;-)))
+ $q = sprintf("SELECT COUNT(*) FROM (%s)",
+ eregi_Replace("ORDER[[:space:]]+BY[^\)]*(\)*)", "\\1",
+ $this->lastQuery)
+ );
+
# works also for subselects:
- if (eregi("[[:space:]]+FROM([[:space:]]+.*[[:space:]]+FROM)",$this->lastQuery,$r))
- $areplace=$r[1];
- $q=eregi_Replace("^[[:space:]]*SELECT[[:space:]]+".
- ".*[[:space:]]+FROM",
- "SELECT COUNT(*) FROM$areplace",
- $this->lastQuery);
+ # if (eregi("[[:space:]]+FROM([[:space:]]+.*[[:space:]]+FROM)",$this->lastQuery,$r))
+ # $areplace=$r[1];
+ # $q=eregi_Replace("^[[:space:]]*SELECT[[:space:]]+".
+ # ".*[[:space:]]+FROM",
+ # "SELECT COUNT(*) FROM$areplace",
+ # $this->lastQuery);
+
if ($this->Debug) echo "<BR>Debug: num_rows: $q<BR>";
-// This is of course faster, but dosn't work in such many cases
-// (and yes, I like regular expressions :)
-// Comment the above (after 'works also for subselects') and uncomment this:
-// $from_pos = strpos(strtoupper($this->lastQuery),"FROM");
-// $q = "SELECT count(*) ". substr($this->lastQuery, $from_pos);
ORA_parse($curs,$q);
ORA_exec($curs);
-
PHPLIB Developers Mailing List. Send messages to <phplib-dev <email protected>>.
To unsubscribe, send "unsubscribe" to <phplib-dev-request <email protected>> in
the body, not the subject, of your message.
- Next message: Michael Haertl: "[PHPLIB-DEV] Some ideas on tpl_form"
- Previous message: kir: "[PHPLIB-DEV] cvs commit"
- Next in thread: kir: "[PHPLIB-DEV] cvs commit"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

