如果您的代码在本地计算机上运行良好但在生产中不起作用,那么您必须清除tmp / cache / model和tmp / cahe / persistance中的所有文件.确保您已授予tmp文件夹的可写权限.
这意味着您必须在添加新字段,删除现有字段或在数据库架构中进行任何更改时更新Cake Model架构.在生产模式下如果未找到模式高速缓存文件,则它将基于数据库上的当前模式创建新的高速缓存文件.在每次执行的开发模式中,它将更新架构缓存.
仍然是它在分页中的问题,那么你必须遵循CakePHP 2.x文档.这里我假设您的代码在ApiLogsController中,方法是索引.根据您的代码应该是文档.
public function index() {
$this->Paginator->settings = array(
'limit' => 50,
'order' => 'ApiLog.id DESC'
'paramType' => 'querystring',
'conditions'=> array('ApiLog.log_type' => 2),
'recursive'=>-1, // should be used with joins
'joins'=>array(
array(
'table'=>'users',
'type'=>'LEFT',
'alias'=>'User',
'conditions'=>array('User.id = ApiLog.user_id')
)
)
);
$data = $this->Paginator->paginate('ApiLog');
$this->set(compact('data'));
}
要么
// your default setting in ApiLogController class
public $components = array('Paginator');
public $paginate = array(
'limit' => 50,
'paramType' => 'querystring'
);
public function index() {
// overriding/extending default settings
$this->Paginator->settings['order']='ApiLog.id DESC';
$this->Paginator->settings['conditions']=array('ApiLog.log_type' => 2),
$this->Paginator->settings['recursive']= -1;
$this->Paginator->settings['joins']=array(
array(
'table'=>'users',
'type'=>'LEFT',
'alias'=>'User',
'conditions'=>array('User.id = ApiLog.user_id')
)
);
$data = $this->Paginator->paginate('ApiLog');
$this->set(compact('data'));
}