On Thu, Aug 13, 2009 at 12:27 PM, subnoodle<[email protected]> wrote: > > Hi Brian, > thank you for clearifing the difference between queryData in this both > contextes, Behavior and Model. > In this case, i need to use i in behavior context. > > Can i do conditions there as well? > > If this is the case, how?
You're creating a behavior? In that case, your best bet would be to have a look at some other ones. Many of them do just this--alter or add conditions. > (e.g., discard the given queryData and return an queryData-Strucure as > array, or making an conditions entry in the given queryData-object- > structure at a specific place....) It's pretty much the same as the code I posted. The big difference is you need to abstract the model: AAARGGH! And I've just realised that the code I posted had a typo and a big error. This: $queryData['conditions'][$model->alias.'.YOUR_FIELD' = 'YOUR_CONDITION'; ... should be: $queryData['conditions'][$this->alias.'.YOUR_FIELD'] = 'YOUR_CONDITION'; ... when it's in Model::beforeFind(). When in a Behavior's beforeFind(), you'd do as I posted: $queryData['conditions'][$model->alias.'.YOUR_FIELD'] = 'YOUR_CONDITION'; You don't want to *discard* the data, just alter it and return it. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" 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 -~----------~----~----~----~------~----~------~--~---
