Re: numRows implementation

From: Date: Thu, 22 Mar 2001 19:26:22 +0000
Subject: Re: numRows implementation
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-66@lists.php.net to get a copy of this message
>> Here we go again, this time with the implementation of the numRows for >> PEAR. We only coded the function for mySQL but it\'s really easy to >> implement for the other databases but... we don\'t have many time :( > > I\'m pretty sure this cannot be ported to oracle ( maybe other databases > too ) mybe this is why it was left out in the first place. With Oracle, to get the number of rows returned by a SELECT query, you have to do a count(*) first with the same query. I used to do it with a regex when using PHPlib DB layer : function makeCountQuery($queryString) { if (eregi(\"^[[:space:]]*SELECT[[:space:]]\",$queryString) ) { $from_pos = strpos(strtoupper($queryString),\"FROM\"); $qry = \"SELECT COUNT(*) \".substr($queryString, $from_pos); return $qry; } else { return false; } } This is pretty easy and maybe could be implemented for databases like Oracle which return rows in a asynchronous way. I have read that even with 2 queries instead of one, performance is still ok because access to the database is cached. So the second query is faster. I haven\'t benchmarked it though. Any opinion is interesting as numrows has always been a problem when switching from Oracle to mySQL. BTW does anybody know if SQL Server supports numrows ? Bertrand Mansion http://www.mamasam.com PS : sorry for the slashes, I am testing a new webmailer of mine as I cannot send mails to this list with my regular smtp server (wanadoo.fr). -- Mamasam on the run.

« previous php.pear.dev (#66) next »