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


PHP PDO::inTransaction方法代码示例

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


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

示例1: inTransaction

 /**
  * Checks if inside a transaction
  *
  * @return bool
  * @throws DatabaseException
  */
 public function inTransaction() : bool
 {
     try {
         return $this->pdo->inTransaction();
     } catch (\PDOException $e) {
         throw DatabaseException::pdoError($e->getMessage());
     }
 }
开发者ID:comelyio,项目名称:comely,代码行数:14,代码来源:AbstractPdo.php

示例2: isTransactionRunning

 public function isTransactionRunning()
 {
     if (method_exists($this->pdo, 'inTransaction')) {
         return $this->pdo->inTransaction();
     } else {
         return parent::isTransactionRunning();
     }
 }
开发者ID:xiaoguizhidao,项目名称:extensiongsd,代码行数:8,代码来源:Driver.php

示例3: RollBack

 /**
  * @test
  */
 public function RollBack()
 {
     $this->transaction->beginTransaction();
     $rollBacked = $this->transaction->rollBack();
     $this->assertTrue($rollBacked);
     $this->assertFalse($this->pdo->inTransaction());
     $this->assertFalse($this->transaction->isTransactionActive());
 }
开发者ID:abdougaye,项目名称:UseCase,代码行数:11,代码来源:PDOTransactionAdapterTest.php

示例4: inTransaction

 /**
  * @see \herosphp\db\interfaces\Idb::inTransaction()
  */
 public function inTransaction()
 {
     if ($this->link == null) {
         $this->connect();
     }
     return $this->link->inTransaction();
 }
开发者ID:yangjian102621,项目名称:herosphp,代码行数:10,代码来源:SingleDB.class.php

示例5: install_schema

 /**
 	Database install
 */
 private static function install_schema()
 {
     $data = $_SESSION;
     $sql = str_replace('[[now]]', time(), file_get_contents('assets/sql/anchor.sql'));
     $dsn = 'mysql:dbname=' . $data['db']['name'] . ';host=' . $data['db']['host'] . ';port=' . $data['db']['port'];
     $dbh = new PDO($dsn, $data['db']['user'], $data['db']['pass']);
     try {
         $dbh->beginTransaction();
         $dbh->exec('SET NAMES `utf8`');
         $dbh->exec($sql);
         // create metadata
         $sql = "INSERT INTO `meta` (`key`, `value`) VALUES ('sitename', ?), ('description', ?), ('theme', ?);";
         $statement = $dbh->prepare($sql);
         $statement->execute(array($data['site']['site_name'], $data['site']['site_description'], $data['site']['theme']));
         // create user account
         $sql = "INSERT INTO `users` (`username`, `password`, `email`, `real_name`, `bio`, `status`, `role`) VALUES (?, ?, ?, 'Administrator', 'Default account for Anchor.', 'active', 'administrator');";
         $statement = $dbh->prepare($sql);
         $statement->execute(array($data['user']['username'], crypt($data['user']['password'], $_SESSION['key']), $data['user']['email']));
         $dbh->commit();
     } catch (PDOException $e) {
         Messages::add($e->getMessage());
         // rollback any changes
         if ($dbh->inTransaction()) {
             $dbh->rollBack();
         }
     }
 }
开发者ID:nathggns,项目名称:anchor-cms,代码行数:30,代码来源:installer.php

示例6: rollback

 /**
  * Rollback.
  * Provides a fluent interface.
  *
  * @return PDOMySQL
  */
 public function rollback()
 {
     if (isset($this->link) && $this->link->inTransaction()) {
         $this->link->rollBack();
     }
     return $this;
 }
开发者ID:artoodetoo,项目名称:dbal,代码行数:13,代码来源:PDOMySQL.php

示例7: inTransaction

 public function inTransaction()
 {
     if (!$this->pdo) {
         return false;
     }
     return $this->pdo->inTransaction();
 }
开发者ID:shabbyrobe,项目名称:pdok,代码行数:7,代码来源:Connector.php

示例8: executeQuery

function executeQuery($sqlCommand, $parameters)
{
    try {
        $connection = new PDO('mysql:dbname=circuito;host=localhost', 'root', '');
        $command = $connection->prepare($sqlCommand);
        if ($parameters != null) {
            foreach ($parameters as $key => $value) {
                $listaRetorno = array();
                $command->bindValue($key, $value);
            }
        }
        $command->execute();
        $listaRetorno = array();
        for ($i = 0; $row = $command->fetch(); $i++) {
            array_push($listaRetorno, $row);
        }
        return $listaRetorno;
    } catch (PDOException $ex) {
        echo $ex->getTraceAsString();
        if ($connection != null) {
            if ($connection->inTransaction()) {
                $connection->rollBack();
            }
        }
        return array();
    }
}
开发者ID:silviogn,项目名称:DAW2_2_2015_CIRCUITO,代码行数:27,代码来源:Dao.php

示例9: executeQuery

function executeQuery($sqlCommand, $parameters)
{
    try {
        $connection = new PDO('mysql:dbname=taller;host=localhost', 'root', 'mysql');
        $command = $connection->prepare($sqlCommand);
        if ($parameters != null) {
            foreach ($parameters as $key => $value) {
                $listaRetorno = array();
                $command->bindValue($key, $value);
                //echo $key."=>".$value."<br>";
            }
        }
        $command->execute();
        $listaRetorno = array();
        for ($i = 0; $row = $command->fetch(PDO::FETCH_ASSOC); $i++) {
            array_push($listaRetorno, $row);
        }
        return $listaRetorno;
    } catch (PDOException $ex) {
        echo $ex->getMessage();
        if ($connection != null) {
            if ($connection->inTransaction()) {
                $connection->rollBack();
            }
        }
        return array();
    } finally {
        //UTILIZADO NA VERSAO DO PHP 5.6 NAS PREVIAS NAO É COMPATÍVEL
        if ($connection != null) {
            //FECHA A CONEXAO COM O BANCO DE DADOS
            $connection = null;
        }
    }
}
开发者ID:moiilopez,项目名称:Taller,代码行数:34,代码来源:Dao.php

示例10: execute

 /**
  * Executes a prepared statement
  *
  * @param array $inputParams An array of values with as many elements as
  *   there are bound parameters in the SQL statement being executed.
  * @throws \PDOException
  * @return bool TRUE on success or FALSE on failure
  */
 public function execute($inputParams = null)
 {
     $mode = OCI_COMMIT_ON_SUCCESS;
     if ($this->_pdoOci8->inTransaction()) {
         $mode = OCI_DEFAULT;
     }
     // Set up bound parameters, if passed in
     if (is_array($inputParams)) {
         foreach ($inputParams as $key => $value) {
             $this->bindParam($key, $inputParams[$key]);
         }
     }
     // The @ won't ignore the error in strict mode, so catch ErrorException
     try {
         $result = @oci_execute($this->_sth, $mode);
     } catch (\ErrorException $e) {
         $result = false;
     }
     if ($result != true) {
         $e = $this->errorInfo();
         $pdo_exception = new \PDOException($e[2], $e[1]);
         $pdo_exception->errorInfo = $e;
         throw $pdo_exception;
     }
     return $result;
 }
开发者ID:alfmel,项目名称:cougar,代码行数:34,代码来源:PDOStatement.php

示例11: rollback

 public function rollback()
 {
     $this->transactionNestingLevel--;
     if ($this->transactionNestingLevel == 0 && $this->db->inTransaction()) {
         $this->db->rollBack();
     }
 }
开发者ID:ashmna,项目名称:LikeTracker,代码行数:7,代码来源:DB.php

示例12: rollbackTransaction

 /**
  * Rollsback a transaction
  *
  * @return bool true on success, false otherwise
  */
 public function rollbackTransaction()
 {
     if (!$this->_connection->inTransaction()) {
         return false;
     }
     return $this->_connection->rollback();
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:12,代码来源:PDODriverTrait.php

示例13: catchError

 /**
  * Almacena los errores
  * @param string $error
  */
 protected function catchError($error)
 {
     if ($this->connection->inTransaction()) {
         $this->errorTran[] = $error;
         $this->stateTran = FALSE;
     }
     $this->lastError = $error;
 }
开发者ID:Ignite-IT,项目名称:enolaphp,代码行数:12,代码来源:DataBaseAR.php

示例14: inTransaction

 public function inTransaction()
 {
     if (!$this->isConnected) {
         return false;
     }
     $this->connect();
     return parent::inTransaction();
 }
开发者ID:gobline,项目名称:pdo,代码行数:8,代码来源:LazyPdo.php

示例15: startTransaction

 /**
  * Starts a transaction
  *
  * @abstract
  * @return void
  */
 public function startTransaction()
 {
     if (!$this->pdoConnection->inTransaction()) {
         if (!$this->pdoConnection->beginTransaction()) {
             throw new RelationalSqlException("Unable to start transaction for unknown reasons");
         }
         return true;
     }
     return false;
 }
开发者ID:ryanzec,项目名称:salvomvc-component,代码行数:16,代码来源:BaseDataSource.php


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