Re: coding practices with models

2009-12-29 Thread Martin Westin
I feel the same way sometimes. It is tempting to use model methods as $record->method() in a way similar to an object-based ORM (e.g. Rails, where class methods are used for finding and instance methods are used for record manipulation). But the way Cake works it is a bit dangerous and I would rec

Re: coding practices with models

2009-12-28 Thread tristan_ph
If you want to instantiate a banana, you should write it like this, $Banana =& ClassRegistry::init('Banana'); then you may now execute the peel() like this, $Banana->peel($id); On Dec 28, 10:14 am, Christian wrote: > When i come across situations that I feel needs to be coded inside the > model

Re: coding practices with models

2009-12-28 Thread robustsolution
in your previous code, you are not instantiating the banana, you are 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 un

Re: coding practices with models

2009-12-28 Thread John Andersen
I use the model class as the maintainer of the individual record and the provider of a collection of records. So in your banana example, my model would know what to do when a controller stated that peeling the banana was required :) Whether or not to read the banana into the model depends on the

coding practices with models

2009-12-27 Thread Christian
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 inst