note 76842 deleted from pdostatement.rowcount by tularis

From: Date: Sat, 06 Sep 2008 08:10:51 +0000
Subject: note 76842 deleted from pdostatement.rowcount by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-144180@lists.php.net to get a copy of this message
Note Submitter: hipska at mac dot com ---- If PDOStatement->rowCount() does not return the number of rows affected by a SELECT statement i use a smaller way to get the number of rows. <?php $sql = 'SELECT name FROM fruit WHERE calories > 100'; $fruits = $db->query($sql); if( count($fruits) > 0 ){ foreach ($fruits as $fruit) { echo 'Name: ' . $fruit['name'] . "\n"; } }else{ echo 'No fruits ...'; } ?> i don't know if that is a correct way, but it works

« previous php.notes (#144180) next »