title: How to solve this error "Undefined variable: id"
body: <p>I'm new to Yii. How to solve this error "Undefined variable: id"? </p>
  
  <pre><code>$adminid = adminuser::model()-&gt;findByPK($id)-&gt;id;
  p($adminid);
  echo $agent-&gt;id;
  </code></pre>
  
  <p>Code for adminuser.php:-</p>
  
  <pre><code>&lt;?php
  
  /**
   * This is the model class for table "adminuser".
   *
   * The followings are the available columns in table 'adminuser':
   * @property integer $id
   * @property string $Name
   * @property string $Email
   * @property string $Password
   * @property string $DateRegistered
   * @property integer $PermissionsLevel
   * @property integer $Active
   *
   * The followings are the available model relations:
   * @property Contactus[] $contactuses
   * @property Contactus[] $contactuses1
   */
  class Adminuser extends CActiveRecord
  {
  /**
   * @return string the associated database table name
   */
  public function tableName()
  {
      return 'adminuser';
  }
  
  /**
   * @return array validation rules for model attributes.
   */
  public function rules()
  {
      // NOTE: you should only define rules for those attributes that
      // will receive user inputs.
      return array(
          array('Email, PermissionsLevel', 'required'),
          array('PermissionsLevel, Active', 'numerical', 'integerOnly'=&gt;true),
          array('Name, Email, Password', 'length', 'max'=&gt;100),
          array('DateRegistered', 'safe'),
          // The following rule is used by search().
          // @todo Please remove those attributes that should not be searched.
          array('id, Name, Email, Password, DateRegistered, PermissionsLevel, Active', 'safe', 'on'=&gt;'search'),
      );
  }
  
  /**
   * @return array relational rules.
   */
  public function relations()
  {
      // NOTE: you may need to adjust the relation name and the related
      // class name for the relations automatically generated below.
      return array(
          'contactuses' =&gt; array(self::HAS_MANY, 'Contactus', 'AdminEmailID'),
          'contactuses1' =&gt; array(self::HAS_MANY, 'Contactus', 'AdminID'),
      );
  }
  
  /**
   * @return array customized attribute labels (name=&gt;label)
   */
  public function attributeLabels()
  {
      return array(
          'id' =&gt; 'ID',
          'Name' =&gt; 'Name',
          'Email' =&gt; 'Email',
          'Password' =&gt; 'Password',
          'DateRegistered' =&gt; 'Date Registered',
          'PermissionsLevel' =&gt; 'Permissions Level',
          'Active' =&gt; 'Active',
      );
  }
  
  /**
   * Retrieves a list of models based on the current search/filter conditions.
   *
   * Typical usecase:
   * - Initialize the model fields with values from filter form.
   * - Execute this method to get CActiveDataProvider instance which will filter
   * models according to data in model fields.
   * - Pass data provider to CGridView, CListView or any similar widget.
   *
   * @return CActiveDataProvider the data provider that can return the models
   * based on the search/filter conditions.
   */
  public function search()
  {
      // @todo Please modify the following code to remove attributes that should not be searched.
  
      $criteria=new CDbCriteria;
  
      $criteria-&gt;compare('id',$this-&gt;id);
      $criteria-&gt;compare('Name',$this-&gt;Name,true);
      $criteria-&gt;compare('Email',$this-&gt;Email,true);
      $criteria-&gt;compare('Password',$this-&gt;Password,true);
      $criteria-&gt;compare('DateRegistered',$this-&gt;DateRegistered,true);
      $criteria-&gt;compare('PermissionsLevel',$this-&gt;PermissionsLevel);
      $criteria-&gt;compare('Active',$this-&gt;Active);
  
      return new CActiveDataProvider($this, array(
          'criteria'=&gt;$criteria,
      ));
  }
  
  /**
   * Returns the static model of the specified AR class.
   * Please note that you should have this exact method in all your CActiveRecord descendants!
   * @param string $className active record class name.
   * @return Adminuser the static model class
   */
  public static function model($className=__CLASS__)
  {
      return parent::model($className);
  }
  </code></pre>
  
  <p>}</p>