本文整理汇总了PHP中ActiveRecordModel::rollback方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecordModel::rollback方法的具体用法?PHP ActiveRecordModel::rollback怎么用?PHP ActiveRecordModel::rollback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActiveRecordModel
的用法示例。
在下文中一共展示了ActiveRecordModel::rollback方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tearDown
public function tearDown()
{
parent::tearDown();
@unlink(ClassLoader::getRealPath('cache.') . 'currencies.php');
$this->setUpCurrency();
ActiveRecordModel::rollback();
}
示例2: tearDown
public function tearDown()
{
ActiveRecordModel::rollback();
foreach ($this->getUsedSchemas() as $table) {
ActiveRecord::removeClassFromPool($table);
$this->db->executeUpdate("ALTER TABLE {$table} AUTO_INCREMENT=" . $this->autoincrements[$table]);
}
self::getApplication()->setRequest(clone $this->originalRequest);
}
示例3: deleteByID
/**
* Removes a product from a database
*
* @param int $recordID
* @return bool
* @throws Exception
*/
public static function deleteByID($recordID)
{
ActiveRecordModel::beginTransaction();
try {
$product = Product::getInstanceByID($recordID, Product::LOAD_DATA);
$filter = $product->getCountUpdateFilter(true);
if ($product->category->get()) {
$product->updateCategoryCounters($filter, $product->category->get());
}
foreach ($product->getAdditionalCategories() as $category) {
$product->updateCategoryCounters($filter, $category);
}
parent::deleteByID(__CLASS__, $recordID);
ActiveRecordModel::commit();
return true;
} catch (Exception $e) {
ActiveRecordModel::rollback();
throw $e;
}
}
示例4: delete
/**
* Removes category by ID and fixes data in parent categories
* (updates activeProductCount and totalProductCount)
*
* @param int $recordID
*/
public function delete()
{
ActiveRecordModel::beginTransaction();
try {
$activeProductCount = $this->activeProductCount->get();
$totalProductCount = $this->totalProductCount->get();
$availableProductCount = $this->availableProductCount->get();
foreach ($this->getPathNodeSet(true) as $node) {
$node->setFieldValue("activeProductCount", "activeProductCount - " . $activeProductCount);
$node->setFieldValue("totalProductCount", "totalProductCount - " . $totalProductCount);
$node->setFieldValue("availableProductCount", "availableProductCount - " . $availableProductCount);
$node->save();
}
ActiveRecordModel::commit();
parent::delete();
} catch (Exception $e) {
ActiveRecordModel::rollback();
throw $e;
}
}
示例5: test_SuiteTearDown
function test_SuiteTearDown()
{
ActiveRecordModel::rollback();
}
示例6: postProcessResponse
protected function postProcessResponse(Response $response)
{
if ($response instanceof ActionRedirectResponse) {
$response = new ActionResponse();
}
if (empty($GLOBALS['stepData'])) {
$stepData = array();
$stepData['steps'] = $this->getCheckoutSteps($this->order);
$stepData['editableSteps'] = $this->getStepStatus($this->order);
$stepData['completedSteps'] = $this->getStepStatus($this->order, true);
$GLOBALS['stepData'] = $stepData;
} else {
$stepData = $GLOBALS['stepData'];
}
foreach ($stepData as $key => $data) {
$response->set($key, $data);
}
if ($this->anonTransactionInitiated) {
ActiveRecordModel::rollback();
}
return $response;
}
示例7: postProcessResponse
protected function postProcessResponse(Response $response)
{
if ($response instanceof ActionRedirectResponse) {
$response = new ActionResponse();
}
$response->set('steps', $this->getCheckoutSteps($this->order));
$response->set('editableSteps', $this->getStepStatus($this->order));
$response->set('completedSteps', $this->getStepStatus($this->order, true));
if ($this->anonTransactionInitiated) {
ActiveRecordModel::rollback();
$this->anonTransactionInitiated = false;
}
return $response;
}
示例8: payCreditCard
/**
* @role login
*/
public function payCreditCard()
{
if ($id = $this->request->get('id')) {
$this->request->set('order', $id);
}
$order = $this->getPaymentOrder();
if ($redirect = $this->validateOrder($order, self::STEP_PAYMENT)) {
return $redirect;
}
// already paid?
if ($order->isPaid->get()) {
return new ActionRedirectResponse('checkout', 'completed');
}
ActiveRecordModel::beginTransaction();
$this->order->setCheckoutStep(CustomerOrder::CHECKOUT_PAY);
$this->order->setPaymentMethod($this->config->get('CC_HANDLER'));
// process payment
$transaction = $this->getTransaction();
$names = explode(' ', $this->request->get('ccName'), 2);
$transaction->firstName->set(array_shift($names));
$transaction->lastName->set(array_shift($names));
$handler = $this->application->getCreditCardHandler($transaction);
if ($this->request->isValueSet('ccType')) {
$handler->setCardType($this->request->get('ccType'));
}
$handler->setCardData($this->request->get('ccNum'), $this->request->get('ccExpiryMonth'), $this->request->get('ccExpiryYear'), $this->request->get('ccCVV'));
if (!$this->buildCreditCardValidator($handler)->isValid()) {
ActiveRecordModel::rollback();
return $this->getPaymentPageRedirect();
}
if ($this->config->get('CC_AUTHONLY')) {
$result = $handler->authorize();
} else {
$result = $handler->authorizeAndCapture();
}
if ($result instanceof TransactionResult) {
$response = $this->registerPayment($result, $handler);
$trans = $this->order->getTransactions()->get(0);
$eavObject = EavObject::getInstance($trans);
$eavObject->setStringIdentifier('creditcard');
$eavObject->save();
$trans->getSpecification()->loadRequestData($this->request);
$trans->save();
} elseif ($result instanceof TransactionError) {
// set error message for credit card form
$validator = $this->buildCreditCardValidator($handler);
$validator->triggerError('creditCardError', $this->translate('_err_processing_cc'));
$validator->saveState();
$response = $this->getPaymentPageRedirect();
} else {
var_dump($result);
throw new Exception('Unknown transaction result type: ' . get_class($result));
}
ActiveRecordModel::commit();
return $response;
}
示例9: delete
/**
* Delete this node with subtree
*
* @return bool
*
* @throws Exception If failed to commit the transaction
*/
public function delete()
{
$className = get_class($this);
$this->load();
$t_r = $this->getFieldValue(self::RIGHT_NODE_FIELD_NAME);
$t_l = $this->getFieldValue(self::LEFT_NODE_FIELD_NAME);
$width = $this->getWidth();
ActiveRecordModel::beginTransaction();
try {
$updates[] = "UPDATE {$className} SET " . self::RIGHT_NODE_FIELD_NAME . " = " . self::RIGHT_NODE_FIELD_NAME . " - {$width} WHERE " . self::RIGHT_NODE_FIELD_NAME . " >= {$t_r}";
$updates[] = "UPDATE {$className} SET " . self::LEFT_NODE_FIELD_NAME . " = " . self::LEFT_NODE_FIELD_NAME . " - {$width} WHERE " . self::LEFT_NODE_FIELD_NAME . " >= {$t_l}";
foreach ($updates as $update) {
self::getLogger()->logQuery($update);
self::getDBConnection()->executeUpdate($update);
}
$result = parent::delete();
ActiveRecordModel::commit();
foreach (ActiveRecord::retrieveFromPool(get_class($this)) as $instance) {
if ($instance->getFieldValue(self::RIGHT_NODE_FIELD_NAME) >= $t_r) {
$instance->setFieldValue(self::RIGHT_NODE_FIELD_NAME, $instance->getFieldValue(self::RIGHT_NODE_FIELD_NAME) - $width);
}
if ($instance->getFieldValue(self::LEFT_NODE_FIELD_NAME) >= $t_l) {
$instance->setFieldValue(self::LEFT_NODE_FIELD_NAME, $instance->getFieldValue(self::LEFT_NODE_FIELD_NAME) - $width);
}
}
} catch (Exception $e) {
ActiveRecordModel::rollback();
throw $e;
}
$this->setID(false);
$this->markAsNotLoaded();
return $result;
}