2012-01-29 10 views
0

著者のユーザーとプロファイルの情報も含まれている投稿のリストを表示するには、プロファイルテーブルは、投稿への直接リンクを持たず、ユーザテーブルを介してリンクされています。CakePHP:SQLSTATE [42S22]:列が見つかりません:1054 'where句'の 'Post'が不明な列

public function index() 
{ 
    $posts = $this->Post->find('all',null,array('contain'=>array('User'=>'Profile'))); 

    $this->set('posts',$this->paginate($posts)); 
} 

しかし、私はこのエラーを取得しています:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Post' in 'where clause' 

任意のアイデアを、ここで問題なのでしょうか?ありがとう

答えて

6

あなたはfindとし、次にpaginateにはなっていません。 paginate自体がモデルのfindメソッドを呼び出して、現在のページの行を取得します。コードを次のように変更してください:

public function index() 
{ 
    $this->paginate = array(
     'contain'=> array('User'=>'Profile') 
    ); 

    $this->set('posts',$this->paginate()); 
} 
関連する問題