title: How to get user id instead of name in Yii framework?
body: <p>I have added getId method in UserIdentity class to get user id instead of username but it doestn't fetch me userid. After adding this getId method, both of the following will result as empty  </p>
  
  <pre><code>          1. Yii::app()-&gt;user-&gt;getId();
            2. Yii::app()-&gt;user-&gt;id;
  </code></pre>
  
  <p>I posted UserIdentity class here, pls help to solve this issue</p>
  
  <pre><code>   class UserIdentity extends CUserIdentity
       {
     private $_id;
      public function authenticate()
  {       
      $users= User::model()-&gt;findByAttributes(array('name'=&gt;$this-&gt;name));
      $password= User::model()-&gt;findByAttributes(array('password'=&gt;$this-&gt;password));
          if($users===null) {
              $this-&gt;errorCode = self::ERROR_USERNAME_INVALID;                
          }
          else if($password===null) {
              $this-&gt;errorCode = self::ERROR_PASSWORD_INVALID;
          }
          else {        
              $this-&gt;_id=$users-&gt;id;   
              $this-&gt;errorCode = self::ERROR_NONE;
  
          }
          return !$this-&gt;errorCode;
  }       
  public function getId()
  {
     return $this-&gt;_id;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>And i tried to use CDbCriteria to get id from user model, it fetches usename column only, id column will come as empty</p>