title: yii "Trying to get property of non-object" at view.php
body: <p>I have a strange problem with my yii application. I have two tables in my database Players - id, name, team_id and Teams - id, name. I can create new players but when I want to see player's profile there is an error -"Trying to get property of non-object" at this line:</p>
  
  <pre><code>'value'=&gt;$model-&gt;team-&gt;NAME,
  </code></pre>
  
  <p>The most strange problem is that when I test url for players with Ids 1 and 2 everything is okay and I see the correct information, but for other ids I have this problem. Here is part of my code:</p>
  
  <p>view.php</p>
  
  <pre><code>&lt;?php $this-&gt;widget('zii.widgets.CDetailView', array(
  'data'=&gt;$model,
  'attributes'=&gt;array(
      'ID',
      'NAME',
      'TEAM_ID', 
      array(
          'label'=&gt;'Отбор',
          'type'=&gt;'text',
          'value'=&gt;$model-&gt;team-&gt;NAME,
      ),
  ),
  )); ?&gt;
  </code></pre>
  
  <p>Players.php</p>
  
  <pre><code>public function relations()
      return array(
        'team' =&gt; array(self::BELONGS_TO, 'TEAMS', 'ID'),
      );
  }
  </code></pre>
  
  <p>Teams.php</p>
  
  <pre><code>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(
          'player' =&gt; array(self::HAS_MANY, 'PLAYERS', 'ID'),
      );
  }
  </code></pre>
  
  <p>PlayersController.php</p>
  
  <pre><code>public function actionView($id)
  {
      $teams = new CActiveDataProvider('Teams');
      $players = new CActiveDataProvider('Players');
      $this-&gt;render('view', array(
          'model'=&gt;$this-&gt;loadModel($id),
      ));
  }
  </code></pre>