Sometimes, or very rarely we might need to access a model in AppController (Application Controller). This could be for fetching values from a table and make it available for all the controllers in the application (AppController is inherited by all the other controllers). Also, often we need to access models that are not associated with a controller.
I faced this when I had to load some User Session values (which is stored in a database table) in my AppController (app_controller.php) to use with a custom Login process. I was actually integrating a single sign-on process in CakePHP with an external application.
The loadModel function came handy here. See the code below.
By just calling the loadModel function and passing the Model name, the model now becomes available to the controller and we could perform any operations on that model.
By using loadModel, we can reduce the overhead of declaring model names in $uses variable.