How to load multiple Models in cakephp controller

You must be aware of function called “loadModel” in cakephp while working in CakePHP controller.

Just for refreshment about how to use loadModel in cakephp Controller


To load 2 models in controller, you must be writing


But in the article we are concerned with How to load more than 1 model in just 1 line code in Cakephp Controller.

To archive this, in your Controller just add this like after the starting PHP tag and before the Class keyword.

var $uses = array(‘ModelA’,’ModelB’);

Just for your reference the full phase code will be


Class AsController extends AppController{
  var $uses = array('ModelA','ModelB');
  public function index(){

Keep Coding 😛