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


PHP PDO::rollBack方法代码示例

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


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

示例1: rollBack

 /**
  * {@inheritdoc}
  */
 public function rollBack()
 {
     $this->profiler->startQuery("ROLLBACK;");
     $result = $this->pdo->rollBack();
     $this->profiler->stopQuery();
     return $result;
 }
开发者ID:samleybrize,项目名称:bugzorcist,代码行数:10,代码来源:PDOProfiler.php

示例2: runMigration

 /**
  * Выполняет запрос миграцию.
  * @param string $migrationName имя миграции
  * @param string $query запрос
  * @param string $type тип миграции
  * @return bool|\Exception|\PDOException
  * @throw \RuntimeException в случае, если не удалось применить
  */
 protected function runMigration($migrationName, $query, $type = 'up')
 {
     if (empty($query)) {
         throw new \RuntimeException('В миграции отсутствует запрос');
     }
     try {
         $this->db->beginTransaction();
         $statement = $this->db->prepare($query);
         $result = $statement->execute();
         if (!$result) {
             throw new \RuntimeException('Запрос не был выполнен');
         }
         $statement->closeCursor();
         if ($type == 'up') {
             $this->addMigrationInfo($migrationName);
         } else {
             $this->removeMigrationInfo($migrationName);
         }
         $this->db->commit();
     } catch (\PDOException $e) {
         $this->db->rollBack();
         throw $e;
     }
     return true;
 }
开发者ID:georgynet,项目名称:migration,代码行数:33,代码来源:BaseMigrationCommand.php

示例3: endTransaction

 /**
  * Ends a transaction with the server.
  *
  * @param bool $commit
  * @return void
  */
 public function endTransaction($commit = false)
 {
     if ($commit) {
         $this->connection->commit();
     } else {
         $this->connection->rollBack();
     }
 }
开发者ID:rawebone,项目名称:percy,代码行数:14,代码来源:MySqlAdapter.php

示例4: rollBack

 public function rollBack()
 {
     $this->transLevel--;
     if (!$this->transactionNestable() || $this->transLevel == 0) {
         $this->dbh->rollBack();
     } else {
         $this->dbh->exec(sprintf("ROLLBACK TO SAVEPOINT LEVEL%d", $this->transLevel));
     }
 }
开发者ID:hzh123,项目名称:my_yaf,代码行数:9,代码来源:HaloPdo.php

示例5: __destruct

 public function __destruct()
 {
     try {
         if (!is_null($this->_conn)) {
             $this->_conn->rollBack();
         }
     } catch (Exception $e) {
     }
 }
开发者ID:andho,项目名称:simdal,代码行数:9,代码来源:PDOAbstract.php

示例6: rollBack

 public function rollBack()
 {
     if ($this->transactionsCount == 1) {
         $this->transactionsCount = 0;
         $this->pdo->rollBack();
     } else {
         --$this->transactionsCount;
     }
 }
开发者ID:artox-lab,项目名称:fairy-database,代码行数:9,代码来源:Connection.php

示例7: rollBack

 public function rollBack()
 {
     if ($this->transactionCounter >= 0) {
         $this->transactionCounter = 0;
         return $this->pdo->rollBack();
     }
     $this->transactionCounter = 0;
     return false;
 }
开发者ID:bugadani,项目名称:DBTiny,代码行数:9,代码来源:PDODriver.php

示例8: run

 /**
  * @param string $script
  */
 public function run($script)
 {
     try {
         $this->pdo->beginTransaction();
         $this->pdo->query($script);
         $this->pdo->commit();
     } catch (\PDOException $e) {
         $this->pdo->rollBack();
     }
 }
开发者ID:belanur,项目名称:docker-example,代码行数:13,代码来源:Migrator.php

示例9: it_can_rollBack_on_error_during_update_user

 public function it_can_rollBack_on_error_during_update_user(User $user)
 {
     $user->getUuid()->willReturn($uuid = Uuid::uuid4());
     $user->getEmailAddress()->willReturn(EmailAddress::get($email = 'nute@gunray.tf'));
     $user->getPassword()->willReturn($password = password_hash('no.jedi.please', PASSWORD_BCRYPT));
     $user->getDisplayName()->willReturn($displayName = 'Nute Gunray');
     $this->pdo->beginTransaction()->shouldBeCalled();
     $exception = new \RuntimeException();
     $this->pdo->prepare(new Argument\Token\StringContainsToken('UPDATE users'))->willThrow($exception);
     $this->pdo->rollBack()->shouldBeCalled();
     $this->shouldThrow($exception)->duringUpdate($user);
 }
开发者ID:jschreuder,项目名称:SpotCms,代码行数:12,代码来源:UserRepositorySpec.php

示例10: replaceTriplet

 /**
  * Replace current token after successful authentication
  * @param $credential
  * @param $token
  * @param $persistentToken
  * @param int $expire
  */
 public function replaceTriplet($credential, $token, $persistentToken, $expire = 0)
 {
     try {
         $this->connection->beginTransaction();
         $this->cleanTriplet($credential, $persistentToken);
         $this->storeTriplet($credential, $token, $persistentToken, $expire);
         $this->connection->commit();
     } catch (\PDOException $e) {
         $this->connection->rollBack();
         throw $e;
     }
 }
开发者ID:jeremycherfas,项目名称:grav-blog,代码行数:19,代码来源:PDO.php

示例11: merge

 /**
  * @param $primaryPid
  * @param $transferPid
  *
  * @return bool
  */
 public function merge($primaryPid, $transferPid)
 {
     try {
         $this->conn->beginTransaction();
         foreach ($this->tables as $t) {
             $this->conn->exec("UPDATE `{$t}` SET `pid` = '{$primaryPid}' WHERE `pid` = '{$transferPid}'");
         }
         $this->conn->exec("DELETE FROM `patient` WHERE `pid` = '{$transferPid}'");
         $this->conn->commit();
         return true;
     } catch (Exception $e) {
         error_log($e->getMessage());
         $this->conn->rollBack();
         return false;
     }
 }
开发者ID:igez,项目名称:gaiaehr,代码行数:22,代码来源:Merge.php

示例12: doRollback

	protected function doRollback( $fname = '' ) {
		if ( $this->mTrxLevel == 0 ) {
			return;
		}
		$this->mConn->rollBack();
		$this->mTrxLevel = 0;
	}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:7,代码来源:DatabaseSqlite.php

示例13: execute

 /**
  * @param String $query
  * @param array $parameters
  * @return int|null|string
  */
 public function execute(string $query, $parameters = array())
 {
     try {
         $this->pdo->beginTransaction();
         $stmt = $this->pdo->prepare($query);
         $stmt->execute($parameters);
         if ($stmt->errorCode() != 0) {
             $this->pdo->rollBack();
             return 0;
         }
         $returnID = $this->pdo->lastInsertId();
         $this->pdo->commit();
         $stmt->closeCursor();
         return $returnID;
     } catch (\Exception $e) {
         $this->log->addError("There was an error during a query: ", [$e->getMessage()]);
         try {
             $this->pdo = $this->connect();
         } catch (\Exception $e2) {
             $this->log->addCritical("Couldn't reconnect to the database: " . $e->getMessage());
             die(1);
         }
     }
     return null;
 }
开发者ID:sovereignbot,项目名称:citadel,代码行数:30,代码来源:Db.php

示例14: transactionRollBack

 /**
  * Rollback transaction
  */
 public function transactionRollBack()
 {
     if (self::$transactionOngoing) {
         self::$conn->rollBack();
         self::$transactionOngoing = false;
     }
 }
开发者ID:stenvala,项目名称:deco-essentials,代码行数:10,代码来源:FluentTableDB.php

示例15: executaSqlRetornoID

 /**
  * Execulta sentenças sql do tipo UPDATE, DELETE, INSERT, CREATE TABLE, etc.
  *
  * @param string $slq
  * @return true - sucesso | false - falha
  */
 public function executaSqlRetornoID($sql)
 {
     $this->ultimoID = null;
     if (!$this->conectarNoBancoDeDados()) {
         return false;
     }
     try {
         $this->conexao->beginTransaction();
         $this->resultado = $this->conexao->prepare($sql);
         $this->resultado->execute();
         if (!$this->resultado) {
             $this->conexao->rollBack();
             $this->desconectar();
             return false;
         }
     } catch (PDOException $erro) {
         $this->conexao->rollBack();
         $this->desconectar();
         return false;
     }
     $this->ultimoID = $this->conexao->lastInsertId();
     $this->conexao->commit();
     $this->desconectar();
     return true;
 }
开发者ID:thejobs,项目名称:DesignJet,代码行数:31,代码来源:BancoDeDados.php


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