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'));
}
我发现这个特别奇怪,因为第一个代码版本是由蛋糕烘焙生成的,应该可以直接使用,不是吗?