note 59226 deleted from pdostatement.rowcount by tularis

From: Date: Sat, 06 Sep 2008 08:11:17 +0000
Subject: note 59226 deleted from pdostatement.rowcount by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-144181@lists.php.net to get a copy of this message
Note Submitter: markjcrane at gmail dot com ---- 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);

« previous php.notes (#144181) next »