Wednesday, February 15, 2012

restricting afterFind() to one method

Hi,

I'm using cakePHP 2.1beta.

I had like to use the afterFind() in a model to massage some data.
However, I would like to restrict its effect to only one method defined
in the controller, and do nothing for the other methods. My initial
though was to do something like this :

function afterFind($results) {
if ($this->method == 'my_special_method') {
foreach ($results as $key => $val) {
# massage data
}
return $results;
}
else {
# no massaging
return $results;
}
}

but apparently, $this does not contain the calling method. Any idea ?

Thanks,
Charles

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate