>From my experiences it is best to not touch the afterFind function as much as you can because you will run into problems down the line with associations and from calling a find with different parameters in different parts of the controller(s). Unless it is something that must be done for all before/after finds, like encrypting/decrypting values being stored in the database.
Creating the Foo::modifyData() would be the path that I would take. On Dec 18, 10:15 am, "[rob desbois]" <[EMAIL PROTECTED]> wrote: > Hi, > > I'm trying to design my app to have fat models and skinny controllers > where possible but having a problem with one particular part of that: > retrieval of associated models. > > I have models Foo and Bar, where (Foo hasOne Bar) and (Bar belongsTo > Foo), which map to DB tables 'foos' and 'bars' respectively. > When data is retrieved from the 'foos' table, it needs to be modified > for the controller - the obvious place for this is Foo::afterFind(). > The trouble I have is if I do $this->Bar->find(...) then the > associated Foo data isn't passed through the Foo model, so those > modifications have to be performed in the BarController instead. > > Am I missing something, approaching this in the wrong way, or is this > just the way it is? > Is there any way I can get around this without having to duplicate > code? The only idea that springs to mind is to make Foo::afterFind() > call a function Foo::modifyData() which the BarController can call as > well with the results. > > I'm using CakePHP 1.1.18.5850 and PHP 5.2.4 on Win32. I can't upgrade > to v1.2 as this is part of a product we sell. > > TIA, > --rob --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~----------~----~----~----~------~----~------~--~---
