I was trying earlier to query some table, and was thrilled of Cake's
associations and recursive options. I usually done wonderfully form
me, but here's what problem I hit.

Let's say I have the following table (on short, a user can have custom
properties that can be classified in several categories):

* users ( id )
* user_property_categories ( id, name ) - has many user_properties
* user_properties (id, user_property_category_id ) - belongs to
user_property_categories
* user_property_values (id, user_property_id, user_id, value ) -
belongs to users, belongs to user_properties

I tried to get the property values in a certain category.
If i try to do this for all users it works beautifully:
---
$this->UserProperty->findAll(  array(
        '`UserPropertyCategory`.`name`'=> "= ".$category
  ),  null,null,null,null,1);
---
This generates 2 queries, 1 to get the properties and categories (join
between these 2 tables), and another to get the actual values (a
select on the property_values table with ' user_property_id IN (.....)
').

It gets ugly when i try to get the properties for all the users. :
---
$this->UserProperty->findAll(  array(
        '`UserPropertyCategory`.`name`'=> "= ".$category,
        '`UserPropertyValue`.`user_id`'=> "= ".$this->getID()
  ),  null,null,null,null,1);
---
This outputs 1054: Unknown column 'UserPropertyValue.user_id' in
'where clause'

It seems that findAll tries puts the where clause in the first query
that has nothing to do with the UserPropertyValues table. I KNOW, I
KNOW, the solution is to do the two queries separately, but since cake
is the one deciding to break the find in 2 queries, it seems absurd
that it cannot figure where to place the clause.

So I'm wondering, am I missing something obvious or is there a way to
handle this kind of cases?

Hope one of you smarties knows the answer :))
Cheers, Cristian
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to