On Tue, Oct 16, 2012 at 6:25 PM, Larry Garfield <larry@xxxxxxxxxxxxxxxx> wrote: > Instead, use PDO, and bind your parameters. As a nice bonus, the result > from a PDO-based query is not a raw resource but an iteratable object, which > means you can foreach() it. > > http://php.net/manual/en/book.pdo.php > > $conn = new PDO(...); > $result = $conn->query("SELECT * FROM items"); > foreach ($result as $record) { > // Do something with each record here. > } > > --Larry Garfield Bonus round: Remember if you do multiple queries to also issue the close when you are done with the current result set: $result->closeCursor(); (not all dbms drivers have this limitation, but defensive coding is defensive.) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php