I've done a fair amount of searching (5+ hours) on this, but I just
cannot work it out.
Consider a set of entities associated like so:
Category <(HABTM)> Listing <(HABTM)> Location
Now, in a controller a search for all Listing's can be done as so
(this works fine):
$this->Listing->findAll();
But what if you want to find all Listing's dependent on conditions on
Location and/or Category? For example, Listings that associate with a
Location with Location.id=3:
$conditions = array(
'Location.id' => 3
);
$this->Listing->findAll($conditions);
This seems that it should work (from an intuitive POV it's how
belongsTo would work), however HABTM tables are not included in the
SQL 'FROM' section (in this case, the SQL would 'SELECT FROM listings'
- but would not 'LEFT JOIN locations'), so the above will fail with an
error.
I've tried the following (and many other even less-successful
approaches besides):
$this->Listing->bind('Location', array('Location' =>
array('conditions' => 'id = ' . 3)));
$this->Listing->bindModel(array('hasAndBelongsToMany' =>
array('Location' => array('conditions' => array('Location.id' =>
3)))));
I'm missing something. It doesn't seem obvious from where I am, but it
probably is to at least some of you. Could anybody explain what trick
I'm missing?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---