如何计算 phalcon 查询返回的行数?

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

如何计算 mysql 查询返回的行数?使用 PHP Phalcon 框架 ..

我的查询

$result = $connection->query("SELECT * FROM robots ORDER BY name");
 echo $result->numRows();
 print_r($result->fetchAll());
  $result = $connection->query("SELECT * FROM robots ORDER BY name");
  $result->setFetchMode(Phalcon\Db::FETCH_NUM);

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

尝试

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

计算结果集的替代方法

$result->count();

count($result);

你可以这样试试Documentation Here

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