Yii Framework Forum: Get user from model by id - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Get user from model by id Rate Topic: -----

#1 User is offline   dreeger 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 12-April 17

Posted 12 April 2017 - 09:39 AM

Hi. I can't get object and its properties from my user model by id.

$user = UserInfo::model()->findByPk(Yii::app()->user->id);
$surname = $user->surname;
return $surname;


And im getting 0...
0

#2 User is offline   reykel 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 67
  • Joined: 21-June 15
  • Location:Camaguey, Cuba

Posted 12 April 2017 - 10:09 PM

Check model name (UserInfo) and field name (surname) and also make sure of course someone is logged....
1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users