是否可以重复使用 Kohana ORM 查询来获取行数?
所以我的查询是这样的...
$records = ORM::factory('category');
添加一个 WHERE 子句是这样...
$records = $records->where('categoryid', 'LIKE', 'aa');
获取分页计数是这样...
$count = $records->count_all();
而我的 where 子句是这样清除的...
SELECT `categories`.* FROM `categories` LIMIT 20 OFFSET 0
随着这一行被注释掉,
//$count = $records->count_all();
我的 SQL 看起来只是很好...
SELECT `categories`.* FROM `categories` WHERE `categoryid` LIKE 'aa' LIMIT 20 OFFSET 0
是否可以按照我尝试的方式使用单个查询,或者我是否必须进行两个重复的相同查询?一份用于计数,一份用于实际结果...
谢谢!
So I have my query as so...
$records = ORM::factory('category');
Add a WHERE clause as so...
$records = $records->where('categoryid', 'LIKE', 'aa');
Grab a count for pagination as so...
$count = $records->count_all();
And my where clause gets cleared away as so...
SELECT `categories`.* FROM `categories` LIMIT 20 OFFSET 0
With this line commented out
//$count = $records->count_all();
My SQL looks just fine...
SELECT `categories`.* FROM `categories` WHERE `categoryid` LIKE 'aa' LIMIT 20 OFFSET 0
Is it possible to use a single query the way I'm trying to or do I have to make two duplicate identical queries? One for the count, and one for the actual results...
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用特殊的
reset(FALSE)
调用:Use special
reset(FALSE)
call: