简体   繁体   English

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

[英]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? 我如何计算mysql查询返回的行数? using PHP Phalcon Framework .. 使用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 请参阅: 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();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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