title: Yii delete active records with relationship
body: <p>I have two tables:</p>
  
  <pre><code>users{
  id
  username
  password
  }
  
  person{
  id
  fname
  lname
  user_id
  }
  </code></pre>
  
  <p>and relation in User model:</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(
          'person'=&gt;array(self::HAS_ONE, 'Person', 'user_id'),
      );
  }
  </code></pre>
  
  <p>In tutorial there was said I can delete both by writting in user controller:</p>
  
  <pre><code>$this-&gt;loadModel($id)-&gt;person-&gt;delete();
  </code></pre>
  
  <p>but it deletes only person record in db.</p>
  
  <p>and if I write:</p>
  
  <pre><code>$this-&gt;loadModel($id)-&gt;with('person')-&gt;delete();
  </code></pre>
  
  <p>This deletes only  user record in db.</p>
  
  <p>How can I delete both using these relations or changing them perhaps? </p>
  
  <p>Of course I could write that in 3 lines:</p>
  
  <pre><code>$user=$this-&gt;loadModel($id);
  Person::model()-&gt;findByPk($user-&gt;person_id)-&gt;delete();
  $user-&gt;delete();
  </code></pre>
  
  <p>and it would delete both.</p>