簡體   English   中英

如何計算phalcon查詢返回的行數?

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

我如何計算mysql查詢返回的行數? 使用PHP Phalcon Framework ..

我的查詢

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

你可以在這里試試這個文檔

$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);

請參閱: http //docs.phalconphp.com/en/latest/api/Phalcon_Db.html

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

計算結果集的替代方法

$result->count();

要么

count($result);

嘗試

$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