A feature that would be good for PEAR::DB

From: Date: Sun, 11 Nov 2001 20:35:50 +0000
Subject: A feature that would be good for PEAR::DB
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-2817@lists.php.net to get a copy of this message
OK... sometimes when I work with an SQL query, this is what I do; ---- $SQL = "select * from theTable"; $result = $db->query($SQL); while ($result->fetchInto($rec)) { // output stuff } ---- However, this throws me into an infinite loop, since when it finishes recursing from the data in $result, it doesn't stop. I end up having to do this with my loop: ---- while ($result->fetchInto($rec)) { if (!is_array($rec)) break; // output stuff } ---- It's not that bad, but it's hackish, and it would be much easier (and also would reduce the server load a litle bit) if $result->fetchInto($rec) returned FALSE when there wasn't another row in the result. it would also make things like this... ----- if ($result->fetchInto($row)) { // do something } else { // do something else } ---- ... a lot easier, in order to check if anything was returned from the query (and then to do something if there was or wasn't), rather than this... ---- if ($result->numRows()>0) { $test = true; } if ($result->fetchInto($row) && $test) { // do something } else { // do something else } ---- ... which is also hackish. Could you guys add this to the ::fetchRow() and ::fetchInto() methods? --Jason

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