我有以下代码来显示帖子列表,其中还包含作者用户和个人资料的信息.配置文件表没有直接链接到帖子,并通过用户表链接.
public function index()
{
$posts = $this->Post->find('all',null,array('contain'=>array('User'=>'Profile')));
$this->set('posts',$this->paginate($posts));
}
Run Code Online (Sandbox Code Playgroud)
但是我收到此错误:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Post' in 'where clause'
Run Code Online (Sandbox Code Playgroud)
有什么想法这里的问题是什么?谢谢
你不应该find
,然后paginate
; paginate
它本身调用模型的find
方法来获取当前页面的行.将您的代码更改为:
public function index()
{
$this->paginate = array(
'contain'=> array('User'=>'Profile')
);
$this->set('posts',$this->paginate());
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2143 次 |
最近记录: |