Re: oracle: get number of rows from a select statement

From: Date: Mon, 11 Sep 2000 23:56:55 +0000
Subject: Re: oracle: get number of rows from a select statement
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-2813@lists.php.net to get a copy of this message
This may be an EVIL way of doing it, but I thought it was pretty clever :) This is done within a class, but you could easily modify it to be a function. Please note that it's probably not the most efficient way, but the only other way I could find was to do "while(fetch_row) $count++", which is spectacularly slow on large recordsets. $str is the sql statement. ----------- $select = eregi("SELECT", $str); if ($select) { //replace 'select <list>' with 'select count(*)' $var = explode("from", $str); $sql = "select count(*) from " . $var[1]; //Get rid of group by/order by $var = explode("group", $sql); $var = explode("order", $var[0]); $sql = $var[0]; $count = odbc_exec($this->con, $sql); odbc_fetch_row($count, 1); $this->rowcount = odbc_result($count, 1); odbc_free_result($count); } ------------ ----- Original Message ----- From: Manuel Lemos <mlemos@acm.org> To: Peter Van Dijck <peter@vardus.com> Cc: <php-db@lists.php.net> Sent: Tuesday, September 12, 2000 8:30 AM Subject: Re: [PHP-DB] oracle: get number of rows from a select statement > Hello Peter, > > On 11-Sep-00 14:07:47, you wrote: > > >as in mysql_num_rows($resultset) > >how do you get the number of rows from a select statement in oracle? > > You may want to use Metabase. It will count the result rows for you with a > single function call (MetabaseNumberOfRows) and you still be able to fetch > result data normally after that. This is not recommended for result sets > with a large number of rows. See the explanation for this and possible > alternatives in Metabase documentation. > > Metabase is a free PHP database abstraction package that you may find here: > > http://phpclasses.UpperDesign.com/browse.html/package/20 > > Regards, > Manuel Lemos > > Web Programming Components using PHP Classes. > Look at: http://phpclasses.UpperDesign.com/?user=mlemos@acm.org > -- > E-mail: mlemos@acm.org > URL: http://www.mlemos.e-na.net/ > PGP key: http://www.mlemos.e-na.net/ManuelLemos.pgp > -- > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.db (#2813) next »