[英]Phalcon ORM Batch Update
Simple Questions, if you Phalcon users .. you know what i want trying to do. 简单的问题,如果您的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());
}
}
I just want to do this query in orm Phalcon : 我只想在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();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.