Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Problem with Query->count() and where conditions
  • Hello, It seems that when doing a count() and we have where() conditions they're just ignored... It's absolutely conter-intuitive. Why would Model_Something::find()->where('category_id', 1)->count() would count ALL the rows from the table and not only the rows where category_id = 1? Is that something planned to resolve this?
  • i have same problem
    i try this page to get 1.1-dev:
    https://github.com/fuel/orm/tree/1.1/develop
    but github gives me this file:
    fuel-orm-v1.0-44-g03cd723.tar.gz
    the problem still exists with this version
    where i can find 1.1-dev?
  • Ok more information about this. I see I've been a bit rude in my last message, sorry for that. :'( It works when the conditions are on the original table from the model. It doesn't work when conditions are on related model. My use-case is pretty easy: I have a Model_Blog and a Model_Category models. Model_Blog is related to Model_Category with a many_to_many relationship. I want to count the number of blog posts from one or many categories. I can't find whether it's possible or not using the ORM.
  • That's fixed in the 1.1-dev branch, may backport it if we release a 1.0.2
  • I'll use the 1.1-dev branch to test it out. Coming back soon to tell you. Thanks!
  • Works perfectly, thanks a lot!

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion