Hi Brian, in the meanwhile i found it out. Thank you for clearifying this again.
So, basically there where two problems which let me search for days on this issue: => api-doc of Cake contains a section with "own behaviors"- description, but there only a link to the call back methods of a model. And exactly there is the difference: Model::beforeFind($queryData) => this appears as the only one in api- doc ModelBehavior::beforeFind(&$model,$query) For me, i really couldn't guess that the header of the one beforeFind is different than another beforeFind-Header, since they are described in the core doc to be the same. Further, $queryData is a different parameter-name than query, but their use a indicated to be the same; also a bit wiring. Return-Value is the third wiring thig: Is described to return 'true', but is expected to return queryData; i read this at a closed bug before. So i could guess it. These are just hints. And if you tell me how to change the doc, i would change it myself (if i'm allowed to - as little contribution). Thanks a lot & regards, Sam On 13 Aug., 18:48, brian <[email protected]> wrote: > 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 -~----------~----~----~----~------~----~------~--~---
