Skip to content

Instantly share code, notes, and snippets.

@intel352
Created September 2, 2011 17:56
Show Gist options
  • Save intel352/1189307 to your computer and use it in GitHub Desktop.
Save intel352/1189307 to your computer and use it in GitHub Desktop.
<?php
$ordersForShipping=new CActiveDataProvider( Orders::model()->with(array(
'cart'=>array(
/*
* Ensure occurs in same query
*/
'together'=>true,
'joinType'=>'INNER JOIN',
'with'=>array(
'items'=>array(
/*
* Ensure they exist without selecting data
*/
'select'=>false,
'together'=>true,
'joinType'=>'INNER JOIN',
'with'=>array(
'shipment'=>array(
'select'=>false,
'together'=>true,
'joinType'=>'LEFT JOIN',
/*
* Important: This condition must exist in WHERE statement, not JOIN
* I think it works here, but needs to be tested with Yii generated query displayed
* Also, the alias in the condition may need correcting
*/
'condition'=>'shipment.id IS NULL'
),
)
),
)
),
)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment