Thank you for the quick answer

I'm implementing a per-query cache behavior, so it would be nice to
have it as a Behavior...

I'm now trying doing a beforeFind/afterFind logic, I will post
results,



On 12 abr, 00:34, cricket <zijn.digi...@gmail.com> wrote:
> You can't override find() in a Behavior. What you can do is create a
> beforeFind() method. That will be called from the model's find().
> However, it's expected that the Behavior should return an array (the
> query data). You can return false, but then the model's find() will
> return null, so I don't know how that would help.
>
> Also, your parent::find() would be calling ModelBehavior. I don't
> think that's likely what you want.
>
> You can do some neat stuff by overriding find() in AppModel. 
> See:http://bakery.cakephp.org/articles/view/quick-tip-doing-ad-hoc-joins-...
>
> But I doubt that's what you're after.
>
> What's this CacheBehavior supposed to do, anyway? And would it make
> more sense if it was a component?
>
> On Apr 12, 1:09 am, Mateo San Román <sanroma...@gmail.com> wrote:
>
>
>
> > Hello,
>
> > I'm currently implementing a Model Cache behavior. In order to work
> > without changing other behaviors, components or helpers, I need to
> > override the default Model::find function, to work like this:
>
> > In behavior:
> >    function find($conditions = null, $fields = array(), $order = null,
> > $recursive = null) {
> >       if (true /*$this->settings[$Model->alias]['auto']*/ )
> >          return $this->cacheFind(&$Model, $type, $conditions, $fields,
> > $order, $recursive);
> >       return parent::find($type, $conditions, $fields, $order,
> > $recursive);
> >    }
>
> > but it keeps calling Model::find before. I've tried doing this with
> > the callbacks, with no luck.
>
> > Thanks in advance.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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

To unsubscribe, reply using "remove me" as the subject.

Reply via email to