开发者

Kohana 3.1 counting ORM find_all results

I might be searching for the wrong keywords as I find it almost impossible that I can't find this in the docs or in any forum anywhere.

from an ORM find_all() query results like

$result = ORM::factory('some_table')->where('id', 'IN', $ids)->find_all()

How can I count the results returned?

I've tried

$results->count()

count($results)

But to no avail am I getting the correct results, always a 1 in the later case since an object is returned.

Or if the count isn't possible then at least something that tells me if any results were found?开发者_如何学Python


I think you have a typo there -- you have assigned the result to $result, but then try to count on $results.

The following code should work:

$result = ORM::factory('some_table')->where('id', 'IN', $ids)->find_all();
echo $result->count();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜