Best way to load models in CakePHP 2.0

后端 未结 3 1822
后悔当初
后悔当初 2020-12-13 10:18

I\'m not sure of the best way to load models in CakePHP 2.0 now.


Question 1

I have a model where more than one database field is relat

3条回答
  •  暖寄归人
    2020-12-13 10:32

    The preferred way is

    $this->load('MyModel');
    

    However, you can also use

    public $uses = array('DefaultModel', 'MyModel');
    .
    .
    $this->MyModel->field(...);
    

    Cake supports both and you are free to use anyone you like.

提交回复
热议问题