Cake Bake生成的代码(脚手架)导致语法错误

时间:2018-06-02 15:11:18

标签: cakephp cakephp-3.0 cakephp-bake

Cake Bake生成了以下代码剪切:

public function index()
{
$this->paginate = [
        'contain' => ['Users']
    ];

    $shops = $this->paginate($this->Shops);

    $this->set(compact('shops'));
}

结果是错误消息:语法错误,意外“使用”(T_USE)

当我将代码更改为此时,它可以工作:

public function index()
{
    $this->paginate = [
        'contain' => ['Users']
    ];

    // $shops = $this->paginate($this->Shops);
    $this->loadComponent('Paginator');
    $shops = $this->Paginator->paginate($this->Shops->find());

    $this->set(compact('shops'));
}

我发现这个特别奇怪,因为第一个代码版本是由蛋糕烘焙生成的,应该可以直接使用,不是吗?

0 个答案:

没有答案