Re: Return Row count with OCI

From: Date: Wed, 23 May 2001 13:05:30 +0000
Subject: Re: Return Row count with OCI
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-9568@lists.php.net to get a copy of this message
Hello, Worawisut Pinyoyang wrote: > > To all PHP-db guruz! > I'm novice on Oracle(OCI).In mysql has mysql_num_rows(). > When i try to find OCI function about num rows i see OCIRowCount(). > But in the manual told me that it cannot use with select statement. > How can i know the number of selected row? Oracle can't tell you that because it starts returning rows as it finds them in the database so the client (PHP) starts getting query results before reaching to the end of the search so it can't tell in advance the number of selected rows. The alternative is to buffer all rows in array but that's resource consuming for large result sets. A better alternative is to issue a first query with SELECT COUNT(*) FROM tables where conditions. Anyway, you may want to Metabase that is a database abstraction package that implements the first technique for the Oracle driver if you use the MetabaseNumberOfRows function. You may download Metabase for free from here: http://phpclasses.UpperDesign.com/browse.html/package/20 Manuel Lemos

« previous php.db (#9568) next »