Skip to content

Instantly share code, notes, and snippets.

@kopasetik
Created November 23, 2014 23:16
Show Gist options
  • Save kopasetik/3c77fb16b1b901df3b61 to your computer and use it in GitHub Desktop.
Save kopasetik/3c77fb16b1b901df3b61 to your computer and use it in GitHub Desktop.
BaseCommand issue
<?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