FAQ #43

Question: How do I use a model in my action, but not the whole controller? Answer: Use the loadModel method. You can the invoke model's properties and methods as usual.
//in your controller's action function:
$this->loadModel('Book');

$books=$this->Book->find('all');

//you can optionally specify an id or ids (in an array) in a second argument:
$this->loadModel('Book',22);

//this will return the data for the book with id #22
$book=$this->Book->read();
Add comment