[eluser]GregX999[/eluser]
Ok, I've hit a speed-bump.
I have a products table, a categories table, and a categories_products table for the HABTM relationship.
One of the fields in the products table is "display" - a boolean.
If I have a category, how do I count all the products in that category that have "display" set to 1?
This doesn't work:
Code:
$selected_category->product->where('display', 1)->count();
It creates this query:
Code:
SELECT COUNT(*) AS `numrows` FROM (`categories_products`) WHERE ( `products`.`display` = 1 ) AND `category_id` = 4
Which is missing the "products" table from the "FROM" portion of the query.
BUT... this seems to work just fine:
Code:
$selected_category->products->where('display', 1)->get();
Is there something missing from the count() function that then get() function has?