You have to get the basics right and read the manual first.

Build your separate models and configure their joins using $belongsTo, $hasMany 
etc. Don't forget to create the relationships properly with joins in the db 
too. Set recursive to 0 and make the model $actsAs Containable (these are best 
done in app_model.php so that the whole app works this ay). Then you can daisy 
your models. For example:

User hasMany Post hasMany Comment

To get a data array containing all posts and comments where the author is 
User.id 100 from within the User model:

$userPosts = $this->find(
        'all',
        array(
                'conditions' => array('User.id' => 100),
                'contain' => array(
                        'Post' => array(
                                'Comment'
                        )
                )
        )
);

If, instead, you were doing from the users_controller:
$userPosts = $this->User->find(
        'all',
        array(
                'conditions' => array('User.id' => 100),
                'contain' => array(
                        'Post' => array(
                                'Comment'
                        )
                )
        )
);

Nice and easy, no model loading and no $uses.

Jeremy Burns
Class Outfit

[email protected]
http://www.classoutfit.com

On 9 Dec 2010, at 09:49, Almudena Garcia wrote:

> Only are loaded the ones that you put there. Or you can load one by one only 
> when you need them.
> 
> 2010/12/9 cake-learner <[email protected]>
> I found it very annoying that everytime i need use another model i
> have to define the table in $uses={}.
> Is this mean model classes(model.php) are not loaded? If all php
> classes are loaded when page is loaded, why limiting from using them
> without defining model names.
> 
> 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 [email protected]
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en
> 
> 
> 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 [email protected]
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

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 [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to