[英]Lithium - How to get the number of fetched rows?
In Lithium, after fetching all rows of a given Model like this: 在锂中,在像这样获取给定模型的所有行之后:
$users = Users::all();
how can I know how many rows were returned? 我怎么知道返回了多少行? I'm using the MySQL connector.
我正在使用MySQL连接器。
Thank you! 谢谢!
If you just want the count 如果你只想计数
$usersCount = Users::count();
If you want the count of your collection 如果您想收集您的收藏
$users = Users::all();
$usersCount = count($users->data())
I think you can also do 我想你也可以
$usersCount = $users->count();
I'm aware the above two methods will return the same result. 我知道上述两种方法将返回相同的结果。
The second method is in case he calls Model::find() instead of Model::all(). 第二种方法是万一他调用Model :: find()而不是Model :: all()。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.