本文整理匯總了PHP中ca_objects::inTransaction方法的典型用法代碼示例。如果您正苦於以下問題:PHP ca_objects::inTransaction方法的具體用法?PHP ca_objects::inTransaction怎麽用?PHP ca_objects::inTransaction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ca_objects
的用法示例。
在下文中一共展示了ca_objects::inTransaction方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: removeAllObjects
/**
* Unlinks any ca_objects rows related to the currently loaded ca_object_lots record. Note that this does *not*
* delete the related objects. It only removes their link to this lot. Note that on error, the database maybe left in
* an inconsistent state where some objects are still linked to the lot. If you want to prevent this then wrap your
* call to removeAllObjects in a transaction and rollback the transaction on error.
*
* @return boolean Returns true on success, false if there were errors.
*/
public function removeAllObjects()
{
if (!($vn_lot_id = $this->getPrimaryKey())) {
return null;
}
$o_db = $this->getDb();
$qr_res = $o_db->query("\n\t\t\t\tSELECT object_id\n\t\t\t\tFROM ca_objects\n\t\t\t\tWHERE\n\t\t\t\t\tlot_id = ? AND deleted = 0\n\t\t\t", (int) $vn_lot_id);
$t_object = new ca_objects();
if ($o_t = $this->getTransaction()) {
$t_object->setTransaction($o_t);
}
$vb_errors = false;
while ($qr_res->nextRow()) {
if ($t_object->load($qr_res->get('object_id'))) {
$t_object->setMode(ACCESS_WRITE);
$t_object->set('lot_id', null);
$t_object->update();
if ($t_object->numErrors()) {
$this->errors = array_merge($this->errors, $t_object->errors);
$vb_errors = true;
}
}
}
if ($t_object->inTransaction()) {
$t_object->removeTransaction(true);
}
return !$vb_errors;
// return true if no errors, false if errors
}