title: Yii MANY_TO_MANY and CDbCriteria
body: <p>I'm trying to create a  CDbCriteria which will be used in a CActiveDataProvider, I need to query a value in the other side of a many to many relation.</p>
  
  <p>I have the following tables:
  order, user_order and user</p>
  
  <p>the relations are declared correctly so I can access
  $order->users[0] and see the data correctly.</p>
  
  <p>I'm trying to build the following criteria:</p>
  
  <pre><code>$criteria=new CDbCriteria;
  $criteria-&gt;with  = array('users');
  if (isset($_SESSION['hideCard'])){
      $criteria-&gt;condition = "fname != 'Card'";
  }
  
  return new CActiveDataProvider(get_class($this), array(
      'criteria'=&gt;$criteria,
      'pagination'=&gt;array('pageSize'=&gt;40)
  ));
  </code></pre>
  
  <p>Which basically will mean that if a session variable is set I want to HIDE all the users with fname of "Card" from the DataProvider.</p>
  
  <p>Any ideas on how to achieve this in a many to many relation?</p>