only looking for the banana record with the specific id.
As for the Banana Model Class, you can define custom methods.
You can do hat ever you want but,
If you want to know how do I think?
I do not put a method in the model unless I know It is going to be
called from more than one controller, otherwise I put it as private
method in the controller
On Dec 28, 2:14 am, Christian <cdamiani...@gmail.com> wrote:
> When i come across situations that I feel needs to be coded inside the
> model I'm not sure whether (form the perspective of the controller or
> a different model) to treat a model as an object, or just as a
> collection of class methods.
>
> For example:
>
> If I want to peel a banana..
>
> Is it correct to instantiate the Banana
> $this->Banana->read(null,$id);
>
> and then call the method
> $this->Banana->peel();
>
> and in banana.php:
> function peel() {
> //since this method was called on a specific instance
> //it should have access to it's private variables (tuple from the
> database)
>
> }
>
> OR do i just call the method on the id and sort that out in the model
>
> $this->Banana->peel($id);
>
> then...
> function peel($id) {
> //need to instantiate the banana first before we can operate on it
> $this->Banana->read(null,$id);
>
> }
>
> I'm curious about the practices of some of you regular cakers.
> thanks
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment