title: yii cdbcriteria: complex joins
body: <p>I recently started a project using Yii and I'm trying to get used to the query builder. Now, I want to make a query using joins and access the joining tables' data in the query but I haven't been able to get the following to work:</p>
  
  <p>My (simplified) db-tables:</p>
  
  <p>customer(#id, name)
  <br />
  employee(#id, name)
  <br />
  customer_employee(#customerid, #employeeid)
  <br />
  accounting(#id, customerid, started_date, finished_date, month, year)</p>
  
  <ul>
  <li>many-to-many relation between customer and employee</li>
  <li>one-to-many relation between customer and accounting</li>
  </ul>
  
  <p>I want to execute the following query, which would select all the customers associated with a certain employee and display their accounting status (started_date &amp; finished_date) if applicable (otherwise null). </p>
  
  <p>The following query works perfectly, it's just that I can't get it to work with the cdbcriteria and Yii query builder: (also, hardcoded id is just for this example)</p>
  
  <pre><code>SELECT name, started_date, finished_date
  FROM customer
  RIGHT JOIN customer_employee ON customer.id=customer_employee.customerid
  LEFT JOIN accounting ON customer.id=accounting.customerid
  WHERE customer_employee.employeeid=2';
  </code></pre>
  
  <p>Please help!</p>