Advantage of loadModel over uses
While using "$uses", many unrelated model gets loaded. So it's best practice to use it only when it is needed through out the controller. If you only need it randomly then loadModel(). Another way of loading a model, if it is in a relationship $this->User->Photo->whatever().
It's syntax is stated below:-
Code
$this->load(ModelName);
$this->ModelName->whatsoever();
OR
Another option is to use this approach:
$ModelName = ClassRegistry::init(ModelName);
Which is nice, because it allows you to do things like this:
$someData = ClassRegistry::init(MyModel)->find(all, array(conditions => array(MyModel.name LIKE => % . $name . % ))); (the latter, chaining, example is PHP5 only).
0 Comment(s)