dongmu4591
dongmu4591
2015-05-23 10:38
浏览 27
已采纳

如何从cakephp 3中的行为访问调用者模型?

I need caller model in my behavior to find and save data. How can I do something like this.

class MyBehavior extends Behavior {
    public function func() {
        $entities = $this->find()->all();
    }
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douwei2825
    douwei2825 2015-05-23 13:18
    已采纳

    The table instance a behavior is attached to, is being passed to the constructor, and assigned to the $_table property.

    public function func() {
        $entities = $this->_table->find()->all();
    }
    

    See also API > Cake\ORM\Behaviour::$_table

    点赞 评论

相关推荐