Hi,

When starting up you will put all query in the controller.

Imagine if the actual query is show in specific controller method more than 
twice.

You will just copy paste right, no problem.

But id it show in 10 place and you wont remember it any more later on as 
project grow.

Then you need to update the query param or something related to the query, you 
like to update it in one place, your model file, or look in each method who use 
the same query.

This is happend in my experience. 

Hope not happen to you . 

Regards,

Mulianto
Blog : Http://muliantophang.blogspot.net


Sent from my iPhone

On 7 Jul 2014, at 14:04, Stephen S <[email protected]> wrote:

> I think you're referring to conventions, and I agree it's best to keep things 
> DRY and place methods to fetch results in the model or app model rather than 
> writing directly in the controller in most instances.
> 
> Personally I would say this is more to do with the MVC pattern rather than 
> CakePHP directly and people will have their own preferences on how to handle 
> this.
> 
> 
> On 6 July 2014 12:09, Jeremy Burns : Class Outfit 
> <[email protected]> wrote:
>> It is using the model. It’s calling the ‘find’ method of the Post model with 
>> the ‘all’ parameter. The Post model is then using the core Model functions 
>> to do the database extraction.
>> 
>> On 6 Jul 2014, at 11:59, Sam Clauw <[email protected]> wrote:
>> 
>>> I've a question about the MVC in CakePHP. Normally, the model should take 
>>> responsability for all the database queries.
>>> 
>>> However, in the cookbook documentation, it seems this isn't respected. See 
>>> the following link: 
>>> http://book.cakephp.org/2.0/en/getting-started.html#create-a-posts-controller
>>> 
>>> As you can see, the index action of PostsController contains 
>>> "$this->Post->find('all')". Shouldn't this and this code for example:
>>> 
>>>>         $this->set('areas', $this->Attraction->Area->find('list', array(
>>>>             'conditions' => array(
>>>>                 'Area.deleted' => null
>>>>             ),
>>>>             'order' => array(
>>>>                 'Area.sequence ASC',
>>>>                 'Area.name ASC'
>>>>             )
>>>>         )));
>>> 
>>> 
>>> not be in the Model part instead of in the controller part???
>>> 
>>> -- 
>>> Like Us on FaceBook https://www.facebook.com/CakePHP
>>> Find us on Twitter http://twitter.com/CakePHP
>>> 
>>> --- 
>>> You received this message because you are subscribed to the Google Groups 
>>> "CakePHP" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at http://groups.google.com/group/cake-php.
>>> For more options, visit https://groups.google.com/d/optout.
>> 
>> -- 
>> Like Us on FaceBook https://www.facebook.com/CakePHP
>> Find us on Twitter http://twitter.com/CakePHP
>> 
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "CakePHP" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at http://groups.google.com/group/cake-php.
>> For more options, visit https://groups.google.com/d/optout.
> 
> 
> 
> -- 
> Kind Regards
>  Stephen Speakman
> -- 
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
> 
> --- 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/cake-php.
> For more options, visit https://groups.google.com/d/optout.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Reply via email to