简单问题,如果你是Phalcon用户......你知道我想要做什么。
$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());
}
}
我只想在orm Phalcon中进行此查询:
UPDATE product_order_transaction set protMomsId = '$monitId' , protMomsName = '$monitName' WHERE protPthdId='$id'
失败 - > rollback .. success - >提交。
答案 0 :(得分:2)
这样的东西?
$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();
}