Simple Questions, if you Phalcon users .. you know what i want trying to do.
$trueFind = ProductOrderTransaction::find(["conditions"=>"protPthdId = ".$id]);
$trueFind->setTransaction($transaction);
$trueFind->protMomsId = $monitId;
$trueFind->protMomsName = $monitName;
if (!$trueFind->update()) {
foreach ($trueFind->getMessages() as $message) {
$this->flash->error($message);
$transaction->rollback($message->getMessage());
}
}
I just want to do this query in orm Phalcon :
UPDATE product_order_transaction set protMomsId = '$monitId' , protMomsName = '$monitName' WHERE protPthdId='$id'
fail -> rollback.. success -> commit.
Something like this?
$items = ProductOrderTransaction::find([
'conditions' => 'protPthdId = :id:',
'bind' => ['id' => $id]
]);
foreach($items as $item){
$this->db->begin();
$item->protMomsId = $monitId;
$item->protMomsName = $monitName;
$update = $item->update();
if(!$update){
$this->db->rollback();
continue;
}
$this->db->commit();
}