title: Findallbyattributes With Related Model
body: <p>I'm trying to do a <code>findAllByAttributes</code> using a related model column as one of the criteria, but I keep getting a <code>CDbException</code> stating <code>the column cannot be found</code>.</p>
  
  <p>Here's my model Relationship:</p>
  
  <pre><code>public function relations() {
    return array(
      'MetaData' =&gt; array(self::BELONGS_TO, 'ProjectMeta', 'wbse_or_io'),
    );
  }
  </code></pre>
  
  <p>And here's my attempted query:</p>
  
  <pre><code>$listing = ProjectIndex::model()-&gt;with('MetaData')
    -&gt;findAllByAttributes(array(
      'report_date'=&gt;$reportDate,
      'MetaData.cost_centre'=&gt;$costCentre
    )
  );
  </code></pre>
  
  <p>From what I've read through Google/StackOverflow/these forums, I should be able to reference the cost_centre column in the MetaData relationship. But I keep getting the following error:</p>
  
  <pre><code>Table "tbl_project_index" does not have a column named "MetaData.cost_centre"
  </code></pre>
  
  <p>How do I reference the related table column? </p>