本文整理汇总了PHP中ca_objects::removeTransaction方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_objects::removeTransaction方法的具体用法?PHP ca_objects::removeTransaction怎么用?PHP ca_objects::removeTransaction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca_objects
的用法示例。
在下文中一共展示了ca_objects::removeTransaction方法的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
}