note 59226 added to function.pdostatement-rowcount

From: Date: Wed, 30 Nov 2005 00:12:35 +0000
Subject: note 59226 added to function.pdostatement-rowcount
Groups: php.notes 
Request: Send a blank email to php-notes+get-99334@lists.php.net to get a copy of this message
A rowcount that would return the record count with a select statement would be extremely usefull in PDO. However since it doesn't exist here is an another method to return the record count. $sql = "SELECT * FROM tblusers "; $prepstatement = $db->prepare($sql); $prepstatement->execute(); //save the results to array $result = $prepstatement->fetchAll(); //count the array $resultcount = count($result); echo "resultcount : ".$resultcount ."<br>"; foreach($result as $field) { echo "username: ".$field[username]."<br>"; echo "<br>"; } unset($sql, $result, $resultcount); ---- Manual Page -- http://www.php.net/manual/en/function.pdostatement-rowcount.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+59226 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59226&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59226&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59226&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59226&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59226&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59226&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59226&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+59226&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#99334) next »