title: Using with and together in Yii
body: <p>I have a grid with paging which displays client data.
  Let's say I have a table <code>Client</code> with <code>name</code>, <code>lastName</code> and <code>address</code> in it, a table <code>Phone_Number</code> which has phone numbers for each of the rows in <code>Client</code> and a table <code>Adress</code> which has adresses for each client. So each <code>Client</code> HAS MANY <code>Phone_Number</code>s and HAS MANY <code>Adress</code>es.</p>
  
  <p>The point is I'm trying to set a limit to the grid's store read. 
  So let's say I set limit = 2. The grid should display only 2 rows per page (2 clients). 
  The problem is that if, for example, client1 has two phone numbers, the query will bring two rows, making the grid display only one client. I am aware that setting <code>together=&gt;false</code> in the query will solve this. But I'm getting an unknown column error whenever I set <code>together=&gt;false</code>.</p>
  
  <p>Here's the code I'm using....</p>
  
  <pre><code>Client::model()-&gt;with(
        'clientPhoneNumbers',
        'clientPhoneNumbers'.'PhoneNumber',
        'clientAddresses',
        'clientAddresses'.'Address'
  )-&gt;findAll(array(condition=&gt;(('Address.s_street_name LIKE :queryString') OR ('PhoneNumber.n_number LIKE :queryString')), params=&gt;$params, order=&gt;$order, limit=&gt;$limit,together=&gt;false));
  </code></pre>
  
  <p>If I do this, I get an error like: <code>Column not found: Address.s_street_name</code> . However, if I set <code>together=&gt;true</code>, it works just "fine".</p>
  
  <p>I found a solution to this problem by doing the query like this....</p>
  
  <pre><code>$with = array(
        'clientPhoneNumbers',
        'clientPhoneNumbers'.'PhoneNumber'=&gt;array(condition=&gt;('PhoneNumber.n_number LIKE :queryString'), params=&gt;array(':queryString'=&gt;$queryString)),
        'clientAddresses',
        'clientAddresses'.'Address'=&gt;array(condition=&gt;('Address.s_street_name LIKE :queryString'), params=&gt;array(':queryString'=&gt;$queryString))
  );
  
  Client::model()-&gt;findAll(array(with=&gt;$with, order=&gt;$order, limit=&gt;$limit,together=&gt;false));
  </code></pre>
  
  <p>The problem is that if I do it like this, the condition is something like this</p>
  
  <pre><code>(('Address.s_street_name LIKE :queryString') AND ('PhoneNumber.n_number LIKE :queryString'))
  </code></pre>
  
  <p>and I need it to be like this</p>
  
  <pre><code>(('Address.s_street_name LIKE :queryString') OR ('PhoneNumber.n_number LIKE :queryString')).
  </code></pre>
  
  <p>Any ideas ?</p>
  
  <p>Keep in mind that the names of the relations and tables are not the actual names. The models and relations where created using Gii</p>