On Sun, Mar 17, 2013 at 1:29 PM, AD7six <[email protected]> wrote:
>
> This does not apply to the blog tutorial in that there _is_ no model code in
> use except basic CRUD functionality.

That's a good point, although when the models become more complex I
prefer to call a method in the model rather than specify a lot of
fields, associations, joins, etc. in the controller. For example:

public function fetchCurrent()
{
        return $this->find(
                'first',
                array(
                        'fields' => array(
                                'Volume.id',
                                'Volume.slug',
                                'Volume.publication_date',
                                'Volume.label',
                                'Volume.in_stock',
                                'Volume.price_domestic',
                                'Volume.price_foreign'
                        ),
                        'order' => array(
                                'Volume.publication_date' => 'DESC'
                        ),
                        'contain' => array(
                                'Image',
                                'Content' => array(
                                        'fields' => array(
                                                'Content.id',
                                                'Content.volume_id',
                                                'Content.content_type_id',
                                                'Content.lang',
                                                'Content.title',
                                                'Content.subtitle',
                                                'Content.abstract',
                                                'Content.abstract_alt'
                                        ),
                                        'order' => array(
                                                'Content.content_type_id' => 
'ASC'
                                        ),
                                        'ContentType',
                                        'Contributor'
                                )
                        )
                )
        );
}

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to