$order = Orders::findFirstById($id);
$order->status = 1;
$trans = $di->get('transactionManager')->get();
try {
$trans->begin() // Is `manually begin` like this?
$order->setTransaction($trans);
if($order->update()) {
$trans->rollback('order save error');
}
$log = new Log();
$log->setTransaction($trans);
if ($log->create()) {
$trans->rollback('log save error');
}
$trans->commit();
} catch (Exception $e) {
//do some other work.
}
When I use $trans->begin()
, the order will not gonna be updated, why?
Do I make mistakes?
In this case, $trans->commit()
do not work.