當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。