I understand that I can specify conditions when I do a find call. But I want it to filter the associated model automatically.
If I am misunderstanding, can you explain what the use of the 'conditions' key is in the hasMany association as described here http://book.cakephp.org/view/82/hasMany On Jun 22, 6:41 pm, brian <bally.z...@gmail.com> wrote: > You shouldn't have conditions in there. You're describing an > association between 2 models, not options for eg. pagination. Jobs > that are > 2 weeks old should still be associated with Recruiter (I'm > guessing is the other model). > > Put those conditions in the controller's $paginate var or whatever > find() call you're making where you only want new Jobs. > > > > On Mon, Jun 22, 2009 at 12:10 PM, abest11<abhishe...@gmail.com> wrote: > > > Hi, > > Im a newbie to Cake, so apologies in advance if this is a silly > > question. I am trying to use a simple hasMany model association with > > a condition on a date field, so that only "Jobs" created in the last > > two weeks are returned. In my model, I have: > > > var $hasMany = array( > > 'Job' => array( > > 'className' => 'Job', > > 'foreignKey' => 'recruiter_id', > > 'conditions' => array("Job.created >" => date('Y-m-d', > > strtotime("-2 > > weeks"))), > > ) > > ); > > > This is based off the manual "Complex Find Conditions" topic. > > > For some reason, I keep getting the error > > "Parse error: syntax error, unexpected '.', expecting ')'" for the > > line which defines the conditions... > > > I can't seem to figure out whats wrong with my syntax. Im using the > > latest version of Cake. > > > Thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---