title: Yii deleteAll() records with condition
body: <p>I've set up a log in process where a verification code is generated, and when successful, is then removed. However, i want to make sure that if there's multiple verification codes for the same user, upon log in success, delete all records for that user.</p>
  
  <p>Here's my code</p>
  
  <pre><code>if ($model-&gt;validate() &amp;&amp; $model-&gt;login()) {
  
      //delete this verification code
      $verificationCode-&gt;delete();
      //delete all existing codes for user_id
      VerificationCode::model()-&gt;deleteAll('user_id',$user-&gt;id);
  
      Yii::app()-&gt;user-&gt;setReturnUrl(array('/system/admin/'));
  
      $this-&gt;redirect(Yii::app()-&gt;user-&gt;returnUrl);
  }
  </code></pre>
  
  <p>However, this seems to just delete all the records, regardless on different user_id's in table. Can anyone see where I'm going wrong?</p>