Ok, I have 3 models: Ad, Classification, Location Ad hasMany Classification,Location Location belongsTo Ad Classification belongsTo Ad I want to be able to search for Ads based on the associated Classifications and Locations. I've tried using something like: <code> $this->Ad->findAll("Classification.id = {$this->data['Classification']['id']} AND Location.id = {$this->data['Location']['id']}"); </code> But this results in: "SQL Error in model Post: 1054: Unknown column 'Classification.id' in 'where clause'" Using Debug: 3, I found that the problem seems to be that when searching on a model with hasMany associations, an SQL alias is not created for the associated modles (ie, Classification as classifications). However, changing my where statment to classifications.id = ... Doesn't seem to help.
If I only wanted to use one of the associated models to limit the results, I would use $this->Ad->Classifications->findAll("Classification.id = {$this->data['Classification']['id']}); which works just fine. Is there some other way I should be doing this? Thanks in advance! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---