fuel / orm

Fuel PHP Framework - Fuel v1.x ORM
http://fuelphp.com/docs/packages/orm/intro.html
151 stars 95 forks source link

help pls count relation #430

Closed hotlabs closed 4 years ago

hotlabs commented 4 years ago

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

WanWizard commented 4 years ago

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.