我正在使用cakephp 2.8,我想访问登录用户的电话号码,有没有快速的方法呢?不使用:
$this->User->find(all,conditions);
conditions=array(Authcomponent::user('id')== 'Profile.user_id')
我不想使用上面的代码,是否有类似的代码:
$this->AuthComponent::user->profile
就像代码一样,我可以使用它来获取配置文件表中用户的电话号码。
答案 0 :(得分:0)
如果你想在视野中这样做,只需:
$phone = $this->Session->read('Auth.User.phone');
如果你想在控制器中使用它:
$phone = $this->Auth->User('phone')