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

时间:2015-03-30 10:29:14

标签: php phalcon

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

我的查询

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

5 个答案:

答案 0 :(得分:3)

您可以尝试这样Documentation Here

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

答案 1 :(得分:2)

  $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

答案 2 :(得分:1)

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

答案 3 :(得分:1)

计算结果集的替代方法

$result->count();

count($result);

答案 4 :(得分:0)

尝试

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