Skip to content

Instantly share code, notes, and snippets.

@intel352
Created September 2, 2011 17:56

Revisions

  1. intel352 revised this gist Sep 2, 2011. 1 changed file with 32 additions and 32 deletions.
    64 changes: 32 additions & 32 deletions gistfile1.aw
    Original file line number Diff line number Diff line change
    @@ -1,34 +1,34 @@
    <?php

    $ordersForShipping=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'
    ),
    )
    ),
    )
    ),
    ))->findAll();
    $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'
    ),
    )
    ),
    )
    ),
    )));
  2. intel352 revised this gist Sep 2, 2011. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions gistfile1.aw
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    <?php

    $ordersForShipping=Orders::model()->with(array(
    'cart'=>array(
    /*
  3. intel352 renamed this gist Sep 2, 2011. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions gistfile1.txt → gistfile1.aw
    Original file line number Diff line number Diff line change
    @@ -5,8 +5,6 @@ $ordersForShipping=Orders::model()->with(array(
    */
    'together'=>true,
    'joinType'=>'INNER JOIN',
    //'select'=>false,
    //'condition'=>'posts.published=1',
    'with'=>array(
    'items'=>array(
    /*
  4. @acodesmith acodesmith created this gist Sep 2, 2011.
    34 changes: 34 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    $ordersForShipping=Orders::model()->with(array(
    'cart'=>array(
    /*
    * Ensure occurs in same query
    */
    'together'=>true,
    'joinType'=>'INNER JOIN',
    //'select'=>false,
    //'condition'=>'posts.published=1',
    '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'
    ),
    )
    ),
    )
    ),
    ))->findAll();