本文整理汇总了PHP中Propel\Runtime\Connection\ConnectionInterface::rollback方法的典型用法代码示例。如果您正苦于以下问题:PHP ConnectionInterface::rollback方法的具体用法?PHP ConnectionInterface::rollback怎么用?PHP ConnectionInterface::rollback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propel\Runtime\Connection\ConnectionInterface
的用法示例。
在下文中一共展示了ConnectionInterface::rollback方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createNumber
/**
* @throws \Spryker\Zed\SequenceNumber\Business\Exception\InvalidSequenceNumberException
*
* @return int
*/
protected function createNumber()
{
try {
$this->connection->beginTransaction();
$sequence = $this->getSequence();
$idCurrent = $sequence->getCurrentId() + $this->randomNumberGenerator->generate();
$sequence->setCurrentId($idCurrent);
$sequence->save();
$this->connection->commit();
} catch (\Exception $e) {
$this->connection->rollback();
throw new InvalidSequenceNumberException('Could not generate sequence number. Make sure your settings are complete. Error: ' . $e->getMessage());
}
return $idCurrent;
}
示例2: tearDown
protected function tearDown()
{
parent::tearDown();
$this->con->exec("SET FOREIGN_KEY_CHECKS = 1;");
$this->con->rollback();
}
示例3: importJsonPrice
public static function importJsonPrice(SocolissimoDeliveryMode $deliveryMode, ConnectionInterface $con)
{
$areaPrices = self::getPrices($deliveryMode);
$priceExist = SocolissimoPriceQuery::create()->filterByDeliveryModeId($deliveryMode->getId())->findOne();
//If at least one price exist doesn't import the xml (or it will erase the user price)
if (null !== $priceExist) {
return;
}
$con->beginTransaction();
try {
foreach ($areaPrices as $areaId => $area) {
foreach ($area['slices'] as $weight => $price) {
$slice = (new SocolissimoPrice())->setAreaId($areaId)->setWeightMax($weight)->setPrice($price)->setDeliveryModeId($deliveryMode->getId());
$slice->save();
}
$con->commit();
}
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}