fuel/orm

help pls count relation

hotlabs opened this issue · 1 comments

im have model - Model_Category
and relation $_many_many = array('posts')

how can i get lists categoryes and get count relation
like:
category (100posts)
category2 (300posts)
category3 (600posts)

$cats= Model_Category::query()->get();
foreach($cats as $cat){
echo $cat->name . ' ' . count($cat->posts);
}
-> this method not good
im need only count - and not full posts lists
because there are a lot of posts

The ORM is not a query builder, so don't use it as such. Instead, use the query builder, DB, to construct the query.

p.s. for user questions, please use the forum, the issue tracker is for issues.