1

简单的问题,如果您是 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'

失败->回滚..成功->提交。

4

1 回答 1

1

像这样的东西?

$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();
}
于 2016-09-13T15:42:39.353 回答