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


PHP Context::rollBack方法代码示例

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


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

示例1: processUpdate

 /**
  * @param \NetteAddons\Model\Importers\IAddonVersionsImporter
  * @param string
  * @param int
  */
 private function processUpdate(IAddonVersionsImporter $addonVersionImporter, $url, $id)
 {
     try {
         $this->db->beginTransaction();
         $addon = $addonVersionImporter->getAddon($url);
         /** @var \Nette\Database\Table\ActiveRow $row */
         $row = $this->db->table('addons')->get($id);
         if (!$row) {
             $this->db->rollBack();
             return;
         }
         $row->update(array('composerVendor' => $addon->getComposerVendor(), 'composerName' => $addon->getComposerName(), 'shortDescription' => Strings::truncate($addon->getPerex(), 250), 'stars' => $addon->getStars()));
         $this->db->table('addons_versions')->where('addonId = ?', $id)->delete();
         $row = $this->db->table('addons_resources')->where('addonId = ? AND type = ?', $id, AddonResources::RESOURCE_PACKAGIST)->fetch();
         if ($row) {
             if ($addon->getPackagist() === null) {
                 $row->delete();
             } else {
                 $row->update(array('resource' => $addon->getPackagist()));
             }
         } elseif ($addon->getPackagist() !== null) {
             $this->db->table('addons_resources')->insert(array('addonId' => $id, 'type' => AddonResources::RESOURCE_PACKAGIST, 'resource' => $addon->getPackagist()));
         }
         $row = $this->db->table('addons_resources')->where('addonId = ? AND type = ?', $id, AddonResources::RESOURCE_GITHUB)->fetch();
         if ($row) {
             if ($addon->getGithub() === null) {
                 $row->delete();
             } else {
                 $row->update(array('resource' => $addon->getGithub()));
             }
         } elseif ($addon->getGithub() !== null) {
             $this->db->table('addons_resources')->insert(array('addonId' => $id, 'type' => AddonResources::RESOURCE_GITHUB, 'resource' => $addon->getGithub()));
         }
         foreach ($addon->getVersions() as $version) {
             /** @var \Nette\Database\Table\ActiveRow $row */
             $row = $this->db->table('addons_versions')->insert(array('addonId' => $id, 'version' => $version->getVersion(), 'license' => implode(', ', $version->getLicenses()), 'distType' => 'zip', 'distUrl' => 'https://nette.org', 'updatedAt' => new DateTime(), 'composerJson' => ''));
             if (!$row) {
                 $this->db->rollBack();
                 return;
             }
             foreach ($version->getDependencies() as $dependency) {
                 // @todo addon link
                 $this->db->table('addons_dependencies')->insert(array('versionId' => $row->id, 'packageName' => $dependency->getDependencyName(), 'version' => $dependency->getDependencyVersion(), 'type' => $dependency->getType()));
             }
         }
         $this->db->commit();
     } catch (\Exception $e) {
         Debugger::log($e);
         $this->db->rollBack();
     }
 }
开发者ID:newPOPE,项目名称:web-addons.nette.org,代码行数:56,代码来源:AddonUpdaterService.php

示例2: actionDefault

 public function actionDefault()
 {
     try {
         $this->db->beginTransaction();
         $this->db->table('addons_resources')->delete();
         foreach ($this->db->table('addons') as $addon) {
             $this->updateAddon($addon);
         }
         $this->db->commit();
     } catch (\PDOException $e) {
         Debugger::log($e);
         $this->db->rollBack();
     }
 }
开发者ID:newPOPE,项目名称:web-addons.nette.org,代码行数:14,代码来源:ResourcesPresenter.php

示例3: register

 public function register($username, $password)
 {
     try {
         $this->database->beginTransaction();
         $this->database->table(self::TABLE_NAME)->insert(array(self::COLUMN_USERNAME => $username, self::COLUMN_PASSWORD_HASH => "xxx"));
         $row = $this->database->table(self::TABLE_NAME)->select(self::COLUMN_DATE)->where(self::COLUMN_USERNAME, $username)->fetch();
         $hash = md5($password . $row[self::COLUMN_DATE]);
         $this->database->table(self::TABLE_NAME)->where(self::COLUMN_USERNAME, $username)->update(array(self::COLUMN_PASSWORD_HASH => $hash));
         $this->database->commit();
     } catch (\Exception $ex) {
         $this->database->rollBack();
         throw $ex;
     }
 }
开发者ID:k4ny,项目名称:NetteRestApiExample,代码行数:14,代码来源:UserModel.php

示例4: parseAndRunFile

 /**
  * Import taken from Adminer, slightly modified
  *
  * @param string $query
  * @return int number of done queries OR array in case of error
  *
  * @author Jakub Vrána, Jan Tvrdík, Michael Moravec, Martin Lukeš
  * @license Apache License
  */
 private function parseAndRunFile($query)
 {
     $delimiter = ';';
     $offset = 0;
     $state = array();
     try {
         $this->db->beginTransaction();
         while ($query != '') {
             if (!$offset && preg_match('~^\\s*DELIMITER\\s+(.+)~i', $query, $match)) {
                 $delimiter = $match[1];
                 $query = substr($query, strlen($match[0]));
             } else {
                 preg_match('(' . preg_quote($delimiter) . '|[\'`"]|/\\*|-- |#|$)', $query, $match, PREG_OFFSET_CAPTURE, $offset);
                 // should always match
                 $found = $match[0][0];
                 $offset = $match[0][1] + strlen($found);
                 if (!$found && rtrim($query) === '') {
                     break;
                 }
                 if (!$found || $found == $delimiter) {
                     // end of a query
                     $q = substr($query, 0, $match[0][1]);
                     //change definer (must be previously definened)
                     if (!empty($this->definerUser) || !empty($this->definerHost)) {
                         $definerMatches = array();
                         preg_match('/(DEFINER\\s*=\\s*)(`[^`]+`)@(`[^`]+`)/', $q, $definerMatches);
                         $newUser = empty($this->definerUser) ? $definerMatches[2] : $this->definerUser;
                         $newHost = empty($this->definerHost) ? $definerMatches[3] : $this->definerHost;
                         $q = preg_replace('/(DEFINER\\s*=\\s*)(`[^`]+`)@(`[^`]+`)/', '$1`' . $newUser . '`@`' . $newHost . '`', $q);
                     }
                     $state[] = $this->db->query($q);
                     $query = substr($query, $offset);
                     $offset = 0;
                 } else {
                     // find matching quote or comment end
                     while (preg_match('~' . ($found == '/*' ? '\\*/' : (preg_match('~-- |#~', $found) ? "\n" : "{$found}|\\\\.")) . '|$~s', $query, $match, PREG_OFFSET_CAPTURE, $offset)) {
                         //! respect sql_mode NO_BACKSLASH_ESCAPES
                         $s = $match[0][0];
                         $offset = $match[0][1] + strlen($s);
                         if ($s[0] !== '\\') {
                             break;
                         }
                     }
                 }
             }
         }
         $this->db->commit();
         $result = count($state);
     } catch (\Exception $ex) {
         $this->db->rollBack();
         $result = array("message" => $ex->getMessage(), "sql" => $q);
     }
     $this->db->query('USE `' . $this->dbName . '`');
     // revert used database
     return $result;
 }
开发者ID:meridius,项目名称:yadup,代码行数:65,代码来源:UpdatorService.php

示例5: addTranslation

 /**
  * @param  string $idf
  * @param  int $amountType
  * @param  string $translation
  * @return DatabaseTranslator
  */
 private function addTranslation($idf, $amountType, $translation)
 {
     try {
         $this->database->beginTransaction();
         $this->database->table(self::TABLE_TRANS)->insert(array('idf' => $idf, 'lang' => $this->lang, 'amount_type' => $amountType, 'translation' => $translation));
         $this->database->commit();
     } catch (\PDOException $e) {
         $this->database->rollBack();
         throw $e;
     }
     $this->invalidate(TRUE);
     return $this;
 }
开发者ID:uestla,项目名称:database-translator,代码行数:19,代码来源:DatabaseTranslator.php

示例6: addHodnoceni

 public function addHodnoceni($id, $hodnoceni, $ip)
 {
     if (abs($hodnoceni) != 1) {
         return;
     }
     $this->database->beginTransaction();
     $h = $this->getHodnoceniByIp($id, $ip);
     if (empty($h)) {
         $arr = array("clanek_id" => $id, "hodnoceni" => $hodnoceni, "ip" => $ip);
         $this->database->query("INSERT INTO hodnoceni ", $arr);
         $this->database->commit();
     } else {
         $this->database->rollBack();
     }
 }
开发者ID:stanley89,项目名称:piratskelisty,代码行数:15,代码来源:Clanky.php

示例7: rollBack

 /**
  * @return void
  */
 public function rollBack()
 {
     if ($this->config->isNestedTransactions()) {
         $this->transactionLevel--;
         if ($this->transactionLevel == 0) {
             $this->context->rollBack();
         } elseif ($this->transactionLevel > 0) {
             $this->context->query("ROLLBACK TO SAVEPOINT level{$this->transactionLevel}");
         } else {
             throw new InvalidStateException("Negative transaction level. Check if each commit/rollBack has its corresponding beginTransaction.");
         }
     } else {
         $this->context->rollBack();
     }
 }
开发者ID:filsedla,项目名称:hyperrow,代码行数:18,代码来源:Database.php

示例8: rollbackTransaction

 public function rollbackTransaction()
 {
     $this->context->rollBack();
 }
开发者ID:VasekPurchart,项目名称:khanovaskola-v3,代码行数:4,代码来源:NetteDbDriver.php


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