Use a model in a component

前端 未结 3 1225
我在风中等你
我在风中等你 2021-02-07 02:07

How do I use a model in a component in CakePHP?

In a controller you can use

public $uses = array(...);

but that doesn\'t work in a

3条回答
  •  情书的邮戳
    2021-02-07 02:52

    You could do it this way:

    $this->ModelName = ClassRegistry::init('ModelName');
    

    But it is suppose you don't use Models inside components.

提交回复
热议问题