Re: DB: numRows()

From: Date: Wed, 22 Nov 2000 17:16:32 +0000
Subject: Re: DB: numRows()
Groups: php.pear 
Request: Send a blank email to php-pear+get-461@lists.php.net to get a copy of this message
As far as ODBC is concerned, the native odbc_num_rows will not work with SELECT statements in some (in my experience: most) drivers. The function is thus similiar to *_affected_rows I have encountered this problem earlier, and solved it in the following way: function numRows($iResult) { $strNewQuery = eregi_replace("(SELECT) .* (FROM.*)", "\\1 COUNT(*) \\2", $this->arrHistory[$iResult]); $iResult = $this->query($strNewQuery); $arrCount = $this->fetch_array($iResult); return $arrCount[0]; break; } This introduces two additional problems: 1) An extra query is required for each numRows call. 2) Upon every ->query, an array ($arrHistory) containing the SQL-query and with the result identifier as key, is written to. That imposes additional overhead for each call to ->query. I believe a similiar approach could be used for sybase, ibase and oci8 /A

« previous php.pear (#461) next »