Friday, June 22, 2012

Re: $this->loadModel and performance

I think you could do as below, without using loadModel…..

$this->paginate = array(
'conditions' => array(
'Post.user_id' => $userId
),
'order' => array(
'Post.created' => 'ASC'
),
'limit' => 100,
'maxLimit' => 100
);
$posts = $this->paginate($this->User->Post);
$this->set(compact('posts'));

check the sql and print_r($posts) …  make sure to only pull data what you need,  use fields, recursive, contain….

Andras Kende



On Jun 22, 2012, at 6:40 AM, JonStark wrote:

Even when having relationships (hasMany and such) implemented, I feel the need to user $this->loadModel to display related data. Indeed, when a User has 450 posts, there is a need to limit the number of associated data returned. But when I want to paginate all posts for a user profile, I use $this->loadModel .

But my question is : does it have an inpact on general performance ?

Thanks for your answers/ experience.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
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

No comments: