Created
November 23, 2014 23:16
-
-
Save kopasetik/3c77fb16b1b901df3b61 to your computer and use it in GitHub Desktop.
BaseCommand issue
This file contains 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 | |
class OrdersCloseCommand extends BaseCommand | |
{ | |
public function run($args) | |
{ | |
parent::run($args); | |
// var_dump(Yii::app()->assetManager->publish(Yii::getPathOfAlias('application.assets')));exit; | |
$openOrders = Yii::app()->db->createCommand() | |
->select('*') | |
->from('order') | |
->where(array('AND', | |
"DATE_ADD(NOW(), INTERVAL -:diff SECOND) > create_time", | |
'status = "new"' | |
), | |
[":diff"=>Yii::app()->params["openOrdersLifeTime"]]) | |
->query(); | |
foreach ($openOrders as $openOrder) { | |
$order = Order::model()->findByPk($openOrder["id"]); | |
$orderItems = $order->furnitures; | |
foreach ( $orderItems as $item) | |
{ | |
$order->removeFurniture( $item ); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment