简体   繁体   中英

How can I count the numbers of rows that a phalcon query returned?

How can I count the numbers of rows that a mysql query returned? using PHP Phalcon Framework ..

My Query

$result = $connection->query("SELECT * FROM robots ORDER BY name");

You may try like this Documentation Here

$result = $connection->query("SELECT * FROM robots ORDER BY name");
echo 'There are ', $result->numRows(), ' rows in the resulset';
  $result = $connection->query("SELECT * FROM robots ORDER BY name");
  $result->setFetchMode(Phalcon\Db::FETCH_NUM);

Refer : http://docs.phalconphp.com/en/latest/api/Phalcon_Db.html

 echo $result->numRows();
 print_r($result->fetchAll());

Alternative way to count the resultset

$result->count();

or

count($result);

Try

$result = $connection->query("SELECT * FROM robots ORDER BY name");
echo $result->numRows();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM