title: Add relationship between two models
body: <p>I have model 1 represent a table with (id1,par1, para2 ) and model 2 represent a table with (id2,para3)</p>
  
  <p>I want to modify model 1 in order when I use </p>
  
  <pre><code>$mydata = model1::model()-&gt;findBySql('SELECT * FROM table1 ORDER BY id1 DESC');
  </code></pre>
  
  <p>this query return for me directly only where par1 > par3 (both of them are time), without adding the condition where . Or if thee is a method to add a condition where based in other model ?</p>
  
  <pre><code>  class model1 extends CActiveRecord
     {
  
  public static function model($className=__CLASS__)
  {
      return parent::model($className);
  }
  
  public function tableName()
    {
      return 'table1';
    } 
    }
  </code></pre>
  
  <p>Many thanks.</p>