当前位置: 首页>>代码示例>>PHP>>正文


PHP ConnectionInterface::commit方法代码示例

本文整理汇总了PHP中Propel\Runtime\Connection\ConnectionInterface::commit方法的典型用法代码示例。如果您正苦于以下问题:PHP ConnectionInterface::commit方法的具体用法?PHP ConnectionInterface::commit怎么用?PHP ConnectionInterface::commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Propel\Runtime\Connection\ConnectionInterface的用法示例。


在下文中一共展示了ConnectionInterface::commit方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: applyXml

 /**
  * @param string $xml
  *
  * @return Database|boolean
  */
 public function applyXml($xml, $changeRequired = false)
 {
     $this->readDatabase();
     $builder = new QuickBuilder();
     $builder->setPlatform($this->database->getPlatform());
     $builder->setSchema($xml);
     $database = $builder->getDatabase();
     $database->setSchema('migration');
     $database->setPlatform($this->database->getPlatform());
     $diff = DatabaseComparator::computeDiff($this->database, $database);
     if (false === $diff) {
         if ($changeRequired) {
             throw new BuildException(sprintf("No changes in schema to current database: \nSchema database:\n%s\n\nCurrent Database:\n%s", $database, $this->database));
         }
         return false;
     }
     $sql = $this->database->getPlatform()->getModifyDatabaseDDL($diff);
     $this->con->beginTransaction();
     if (!$sql) {
         throw new BuildException(sprintf('Ooops. There is a diff between current database and schema xml but no SQL has been generated. Change: %s', $diff));
     }
     $statements = SqlParser::parseString($sql);
     foreach ($statements as $statement) {
         try {
             $stmt = $this->con->prepare($statement);
             $stmt->execute();
         } catch (\Exception $e) {
             throw new BuildException(sprintf("Can not execute SQL: \n%s\nFrom database: \n%s\n\nTo database: \n%s\n", $statement, $this->database, $database), null, $e);
         }
     }
     $this->con->commit();
     return $database;
 }
开发者ID:bondarovich,项目名称:Propel2,代码行数:38,代码来源:MigrationTestCase.php

示例2: applyXml

 /**
  * @param string $xml
  *
  * @return Database
  */
 public function applyXml($xml)
 {
     $this->readDatabase();
     $builder = new QuickBuilder();
     $builder->setPlatform($this->database->getPlatform());
     $builder->setSchema($xml);
     $database = $builder->getDatabase();
     $database->setSchema('migration');
     $database->setPlatform($this->database->getPlatform());
     $diff = DatabaseComparator::computeDiff($this->database, $database);
     if (false === $diff) {
         return null;
     }
     $sql = $this->database->getPlatform()->getModifyDatabaseDDL($diff);
     $this->con->beginTransaction();
     $statements = SqlParser::parseString($sql);
     foreach ($statements as $statement) {
         try {
             $stmt = $this->con->prepare($statement);
             $stmt->execute();
         } catch (\Exception $e) {
             $this->con->rollBack();
             throw new BuildException(sprintf("Can not execute SQL: \n%s\nFrom database: \n%s\n\nTo database: \n%s\n", $statement, $this->database, $database), null, $e);
         }
     }
     $this->con->commit();
     return $database;
 }
开发者ID:a-melnichuk,项目名称:Movies-Demo,代码行数:33,代码来源:MigrationTestCase.php

示例3: 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;
 }
开发者ID:spryker,项目名称:SequenceNumber,代码行数:20,代码来源:SequenceNumber.php

示例4: saveUrlAndTouch

 /**
  * @param \Generated\Shared\Transfer\UrlTransfer $urlTransfer
  *
  * @return \Generated\Shared\Transfer\UrlTransfer
  */
 public function saveUrlAndTouch(UrlTransfer $urlTransfer)
 {
     $this->connection->beginTransaction();
     $urlTransfer = $this->saveUrl($urlTransfer);
     $this->touchUrlActive($urlTransfer->getIdUrl());
     $this->connection->commit();
     return $urlTransfer;
 }
开发者ID:spryker,项目名称:Url,代码行数:13,代码来源:UrlManager.php

示例5: createRedirectFromTransfer

 /**
  * @param \Generated\Shared\Transfer\RedirectTransfer $redirectTransfer
  *
  * @return \Generated\Shared\Transfer\RedirectTransfer
  */
 protected function createRedirectFromTransfer(RedirectTransfer $redirectTransfer)
 {
     $redirectEntity = new SpyUrlRedirect();
     $this->connection->beginTransaction();
     $redirectEntity->fromArray($redirectTransfer->toArray());
     $redirectEntity->save();
     $this->connection->commit();
     $redirectTransfer->setIdUrlRedirect($redirectEntity->getIdUrlRedirect());
     return $redirectTransfer;
 }
开发者ID:spryker,项目名称:Url,代码行数:15,代码来源:RedirectManager.php

示例6: saveTouchRecord

 /**
  * @param string $itemType
  * @param string $itemEvent
  * @param int $idItem
  * @param bool $keyChange
  *
  * @return bool
  */
 public function saveTouchRecord($itemType, $itemEvent, $idItem, $keyChange = false)
 {
     $this->connection->beginTransaction();
     if ($keyChange) {
         $this->insertKeyChangeRecord($itemType, $idItem);
         if ($itemEvent === SpyTouchTableMap::COL_ITEM_EVENT_DELETED) {
             if (!$this->deleteKeyChangeActiveRecord($itemType, $idItem)) {
                 $this->insertTouchRecord($itemType, $itemEvent, $idItem, SpyTouchTableMap::COL_ITEM_EVENT_ACTIVE);
             }
         } else {
             $this->insertTouchRecord($itemType, $itemEvent, $idItem);
         }
     } else {
         $touchEntity = $this->touchQueryContainer->queryUpdateTouchEntry($itemType, $idItem)->findOneOrCreate();
         $this->saveTouchEntity($itemType, $idItem, $itemEvent, $touchEntity);
     }
     $this->connection->commit();
     return true;
 }
开发者ID:spryker,项目名称:Touch,代码行数:27,代码来源:TouchRecord.php

示例7: updateBlocksAssignedToDeletedCategoryNode

 /**
  * @param int $idCategoryNode
  *
  * @return void
  */
 public function updateBlocksAssignedToDeletedCategoryNode($idCategoryNode)
 {
     $this->connection->beginTransaction();
     $assignedBlocks = $this->getCmsBlocksByIdCategoryNode($idCategoryNode);
     foreach ($assignedBlocks as $idBlock => $blockTransfer) {
         //unique keys is on name, type and value therefore the name has to be changed
         $blockTransfer->setName($blockTransfer->getName() . '_' . CmsConstants::RESOURCE_TYPE_CATEGORY_NODE . '_deleted_' . $blockTransfer->getIdCmsBlock());
         $blockTransfer->setType(CmsConstants::RESOURCE_TYPE_STATIC);
         $blockTransfer->setValue(0);
         $this->saveBlockAndTouch($blockTransfer);
     }
     $this->connection->commit();
 }
开发者ID:spryker,项目名称:Cms,代码行数:18,代码来源:BlockManager.php

示例8: addPlaceholderText

 /**
  * @param \Generated\Shared\Transfer\PageTransfer $pageTransfer
  * @param string $placeholder
  * @param string $value
  * @param \Generated\Shared\Transfer\LocaleTransfer|null $localeTransfer
  * @param bool $autoGlossaryKeyIncrement
  *
  * @return \Generated\Shared\Transfer\PageKeyMappingTransfer
  */
 public function addPlaceholderText(PageTransfer $pageTransfer, $placeholder, $value, LocaleTransfer $localeTransfer = null, $autoGlossaryKeyIncrement = true)
 {
     $template = $this->templateManager->getTemplateById($pageTransfer->getFkTemplate());
     $uniquePlaceholder = $placeholder . '-' . $pageTransfer->getIdCmsPage();
     $keyName = $this->generateGlossaryKeyName($template->getTemplateName(), $uniquePlaceholder, $autoGlossaryKeyIncrement);
     $this->connection->beginTransaction();
     $pageKeyMapping = $this->createGlossaryPageKeyMapping($pageTransfer, $placeholder, $keyName, $value, $localeTransfer);
     if (!$this->hasPagePlaceholderMapping($pageTransfer->getIdCmsPage(), $placeholder)) {
         $pageKeyMapping = $this->savePageKeyMapping($pageKeyMapping);
     }
     $this->connection->commit();
     return $pageKeyMapping;
 }
开发者ID:spryker,项目名称:Cms,代码行数:22,代码来源:GlossaryKeyMappingManager.php

示例9: commit

 /**
  * Overrides PDO::commit() to only commit the transaction if we are in the outermost
  * transaction nesting level.
  *
  * @return boolean
  */
 public function commit()
 {
     $return = true;
     $opcount = $this->nestedTransactionCount;
     if ($opcount > 0) {
         if (1 === $opcount) {
             if ($this->isUncommitable) {
                 throw new RollbackException('Cannot commit because a nested transaction was rolled back');
             }
             $return = $this->connection->commit();
             if ($this->useDebug) {
                 $this->log('Commit transaction');
             }
         }
         $this->nestedTransactionCount--;
     }
     return $return;
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:24,代码来源:ConnectionWrapper.php

示例10: deleteCategoryRecursive

 /**
  * @param int $idCategory
  * @param \Generated\Shared\Transfer\LocaleTransfer $localeTransfer
  *
  * @return void
  */
 public function deleteCategoryRecursive($idCategory, LocaleTransfer $localeTransfer)
 {
     $this->connection->beginTransaction();
     $this->removeMappings($idCategory);
     $categoryNodes = $this->categoryQueryContainer->queryAllNodesByCategoryId($idCategory)->find();
     foreach ($categoryNodes as $node) {
         $this->cmsFacade->updateBlocksAssignedToDeletedCategoryNode($node->getIdCategoryNode());
         //TODO: https://spryker.atlassian.net/browse/CD-540
         $children = $this->categoryQueryContainer->queryFirstLevelChildren($node->getIdCategoryNode())->find();
         foreach ($children as $child) {
             $this->deleteCategoryRecursive($child->getFkCategory(), $localeTransfer);
         }
         $nodeExists = $this->categoryQueryContainer->queryNodeById($node->getIdCategoryNode())->count() > 0;
         if ($nodeExists) {
             $this->categoryFacade->deleteNode($node->getIdCategoryNode(), $localeTransfer, true);
         }
     }
     $this->categoryFacade->deleteCategory($idCategory);
     $this->connection->commit();
 }
开发者ID:spryker,项目名称:ProductCategory,代码行数:26,代码来源:ProductCategoryManager.php

示例11: deleteNode

 /**
  * @param int $idNode
  * @param \Generated\Shared\Transfer\LocaleTransfer $locale
  * @param bool $deleteChildren
  *
  * @return int
  */
 public function deleteNode($idNode, LocaleTransfer $locale, $deleteChildren = false)
 {
     $this->connection->beginTransaction();
     // Order of execution matters, these must be called before node is deleted
     $this->removeNodeUrl($idNode, $locale);
     $this->touchCategoryDeleted($idNode);
     $hasChildren = $this->categoryTreeReader->hasChildren($idNode);
     if ($deleteChildren && $hasChildren) {
         $childNodes = $this->categoryTreeReader->getChildren($idNode, $locale);
         foreach ($childNodes as $childNode) {
             $this->deleteNode($childNode->getIdCategoryNode(), $locale, true);
         }
     }
     $result = $this->closureTableWriter->delete($idNode);
     $hasChildren = $this->categoryTreeReader->hasChildren($idNode);
     if (!$hasChildren) {
         $result = $this->nodeWriter->delete($idNode);
     }
     $this->touchNavigationUpdated();
     $this->connection->commit();
     return $result;
 }
开发者ID:spryker,项目名称:Category,代码行数:29,代码来源:CategoryTreeWriter.php

示例12: postActivation

 public function postActivation(ConnectionInterface $con = null)
 {
     $con->beginTransaction();
     try {
         if (null === ConfigQuery::read(static::CONFIG_API_KEY)) {
             $this->createConfigValue(static::CONFIG_API_KEY, ["fr_FR" => "Clé d'API pour mailjet", "en_US" => "Api key for mailjet"]);
         }
         if (null === ConfigQuery::read(static::CONFIG_API_SECRET)) {
             $this->createConfigValue(static::CONFIG_API_SECRET, ["fr_FR" => "Secret d'API pour mailjet", "en_US" => "Api secret for mailjet"]);
         }
         if (null === ConfigQuery::read(static::CONFIG_NEWSLETTER_LIST)) {
             $this->createConfigValue(static::CONFIG_NEWSLETTER_LIST, ["fr_FR" => "ALT de la liste de diffusion mailjet", "en_US" => "Diffusion list ALT of mailjet"]);
         }
         if (null === ConfigQuery::read(static::CONFIG_API_WS_ADDRESS)) {
             $this->createConfigValue(static::CONFIG_API_WS_ADDRESS, ["fr_FR" => "Adresse du webservice mailjet", "en_US" => "Address of the mailjet webservice"], "https://api.mailjet.com/v3/REST");
         }
         $database = new Database($con);
         $database->insertSql(null, [__DIR__ . "/Config/thelia.sql"]);
         $con->commit();
     } catch (\Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
开发者ID:Boyquotes,项目名称:Mailjet,代码行数:24,代码来源:Mailjet.php

示例13: 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;
     }
 }
开发者ID:bcbrr,项目名称:SoColissimo,代码行数:22,代码来源:SoColissimo.php


注:本文中的Propel\Runtime\Connection\ConnectionInterface::commit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。