loadModel

Provide access to a model from a Component
Say you have a model called FoosFum in a file called foos_fum.php

loadModel('FoosFum');
$this->FoosFum = &new FoosFum();

Limit the size of your controller

If you only use a model in certain circumstances do not use the $uses array, use loadModel where you need it.

 

References:
http://manual.cakephp.org/chapter/controllers
Google Group
http://manual.cakephp.org/chapter/components

 

 

Advertisements

3 Responses to “loadModel”

  1. Thiago Bocchile Says:

    Hi!
    I was searching for this all the google!…
    You have saved my life! 🙂
    Thanks in advance!

  2. Jahangir Says:

    Hi I have getting error that
    Fatal error: Class ‘Object’ not found in C:\xampp\htdocs\sock\cake\libs\model\datasources\datasource.php on line 37

    while using loadModel function. Could u please guide me how to solve this.I am testing my model. FOr this I required this functionality.

    Reagards,

  3. starkman Says:

    Jahangir,

    This sounds like a configuration issue or something. Try the Google Group or CakePHP website for a solution… Sorry, I don’t have any ideas.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: