Last active
April 8, 2016 06:48
-
-
Save mdmunir/3b4359a2b154426561adf45802fbff97 to your computer and use it in GitHub Desktop.
Sub Query
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $queryGM = (new Query()) | |
| ->select(['gmd.product_id', 'total' => 'sum(gmd.qty)']) | |
| ->from(['gm' => '{{%goods_movement}}']) | |
| ->innerJoin(['gmd' => '{{%goods_movement_dtl}}'], '[[gmd.movement_id]]=[[gm.id]]') | |
| ->where(['gm.status' => 20, 'gm.reff_type' => self::REFF_SELF, 'gm.reff_id' => $this->id]) | |
| ->groupBy(['gmd.product_id']); | |
| $queryItem = (new Query()) | |
| ->select(['md.product_id', 'md.cogs', 'md.qty', 'md.uom_id', 'g.total']) | |
| ->from(['md' => '{{%goods_movement_dtl}}']) | |
| ->leftJoin(['g' => $queryGM], '[[g.product_id]]=[[md.product_id]]') | |
| ->where(['md.movement_id' => $this->id]); | |
| foreach ($queryItem->all() as $item) { | |
| ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment