ログインしているユーザー情報を取得

http://cakephp.jp/modules/newbb/viewtopic.php?topic_id=2573&forum=8

[php]
$userinfo = $this->Auth->user();
debug($userinfo);
[/php]

絞り込むぜいっ!

[php]
//ログインユーザーのIDとレクチャーのIDが同じやつ
$userinfo = $this->Auth->user();
debug($this->Lecture->find(‘all’,array(‘conditions’=>array(‘id’ => $userinfo))));
[/php]

または

[php]
$userinfo = $this->Auth->user(array(‘fields’ => ‘id’)); //ログインしているIDだけ取得
$this->set(‘children’, $this->Child->find(‘all’,array(‘conditions’=>array(‘user_id’=> $userinfo)))); //Childが持っているuser_idとログインのIDの同じやつ
[/php]

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です