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


PHP mysqli::rollback方法代码示例

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


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

示例1: execute

 /**
  * @param string $sql
  * @param array  $queryParams
  *
  * @return bool|\mysqli_result
  * @throws Mysql
  */
 public function execute(string $sql, $queryParams = [])
 {
     // log the query
     $this->log_sql($sql, $queryParams);
     // start sql transaction
     $this->mysqli->begin_transaction();
     // use cache to get prepared statement
     $statement = $this->get_statement_from_sql($sql);
     // bind params
     if (is_array($queryParams) && !empty($queryParams)) {
         $bindTypes = '';
         foreach ($queryParams as $name => $value) {
             $bindTypes .= static::get_bind_type($value);
         }
         $statement->bind_param($bindTypes, ...$queryParams);
     }
     // execute statement
     if (!$statement->execute()) {
         $this->mysqli->rollback();
         throw new Mysql($statement->error, $statement->errno, null, $sql);
     }
     // commit this transaction
     $this->mysqli->commit();
     // save info for latest query
     $this->insertId = $statement->insert_id;
     $this->affectedRows = $statement->affected_rows;
     return $statement->get_result();
 }
开发者ID:justin-robinson,项目名称:scoop,代码行数:35,代码来源:connection.php

示例2: rollback

 /**
  * rollback transaction
  */
 public function rollback()
 {
     if ($this->connection === null) {
         $this->open();
     }
     $this->connection->rollback();
     $this->connection->autocommit(true);
 }
开发者ID:aainc,项目名称:Mahotora,代码行数:11,代码来源:DatabaseSessionImpl.php

示例3: modificaCoche

function modificaCoche($coche)
{
    //alert($coche->login);
    global $servidor, $bd, $usuario, $contrasenia;
    try {
        @($db = new mysqli($servidor, $usuario, $contrasenia));
        if (mysqli_connect_errno() != 0) {
            throw new Exception('Error conectando:' . mysqli_connect_error(), mysqli_connect_errno());
        }
        $db->select_db($bd);
        if ($db->errno != 0) {
            throw new Exception('Error seleccionando bd:' . $db->error, $db->errno);
        }
        $consulta = "update coches set marca='" . $coche->marca . "', modelo='" . $coche->modelo . "', color='" . $coche->color . "' where matricula='" . $coche->matricula . "'";
        if ($db->query($consulta) === false) {
            throw new ExcepcionEnTransaccion();
        }
        $db->commit();
        $db->close();
    } catch (ExcepcionEnTransaccion $e) {
        echo 'No se ha podido realizar la modificacion';
        $db->rollback();
        $db->close();
    } catch (Exception $e) {
        echo $e->getMessage();
        if (mysqli_connect_errno() == 0) {
            $db->close();
        }
        exit;
    }
}
开发者ID:rubenet86,项目名称:projecteAutoEscola,代码行数:31,代码来源:cochesModelo.php

示例4: modificaAlumno

function modificaAlumno($alumno)
{
    global $servidor, $bd, $usuario, $contrasenia;
    try {
        @($db = new mysqli($servidor, $usuario, $contrasenia));
        if (mysqli_connect_errno() != 0) {
            throw new Exception('Error conectando:' . mysqli_connect_error(), mysqli_connect_errno());
        }
        $db->select_db($bd);
        if ($db->errno != 0) {
            throw new Exception('Error seleccionando bd:' . $db->error, $db->errno);
        }
        $consulta = "update alumnos set password='" . $alumno->password . "', nombre='" . $alumno->nombre . "', apellido='" . $alumno->apellido . "', dni='" . $alumno->dni . "', email='" . $alumno->email . "', telefono=" . $alumno->telefono . ", sexo='" . $alumno->sexo . "' where login='" . $alumno->login . "'";
        if ($db->query($consulta) === false) {
            throw new ExcepcionEnTransaccion();
        }
        $db->commit();
        $db->close();
    } catch (ExcepcionEnTransaccion $e) {
        echo 'No se ha podido realizar la modificacion';
        $db->rollback();
        $db->close();
    } catch (Exception $e) {
        echo $e->getMessage();
        if (mysqli_connect_errno() == 0) {
            $db->close();
        }
        exit;
    }
}
开发者ID:rubenet86,项目名称:projecteAutoEscola,代码行数:30,代码来源:alumnosModelo.php

示例5: rollback

 /**
  * Rolls back a transaction.
  *
  * @return Boolean
  */
 public function rollback()
 {
     $this->connect();
     if ($this->connected === TRUE) {
         return $this->mysqli->rollback();
     }
     return FALSE;
 }
开发者ID:rubendgr,项目名称:lunr,代码行数:13,代码来源:MySQLConnection.php

示例6: rollback

 function rollback()
 {
     if ($this->in_transaction > 0) {
         parent::rollback();
         $this->in_transaction = 0;
     }
     return $this->in_transaction;
 }
开发者ID:brainsqueezer,项目名称:fffff,代码行数:8,代码来源:rgdb.php

示例7: rollback

 public function rollback()
 {
     if ($this->logger != null)
     {
         $this->logger->log(Logger::LEVEL_TRACE, __FUNCTION__." called");
     }
     return $this->conn->rollback();
 }
开发者ID:rexfleischer,项目名称:web_dev,代码行数:8,代码来源:DBConnect.php

示例8: rollback

 /**
  * Rollback pending DB transactions.
  *
  * @return boolean true on success
  */
 public function rollback()
 {
     $startTime = microtime(true);
     $ret = $this->db->rollback();
     //gather stats about queries
     $this->addQueryTime(microtime(true) - $startTime);
     return $ret;
 }
开发者ID:Covert-Inferno,项目名称:iveeCore,代码行数:13,代码来源:SDE.php

示例9: rollBack

 /**
  * Rollback (abort) the transaction
  * @throws MysqltcsException on rollback error
  */
 public function rollBack()
 {
     if ($this->mysqliRef->rollback()) {
         $this->log("rollback");
         return;
     }
     $mex = "Mysql error: it is not possible perform the rollback. " . $this->mysqliRef->error;
     $this->log($mex);
     throw new MysqltcsException($mex);
 }
开发者ID:thecsea,项目名称:mysqltcs,代码行数:14,代码来源:Mysqltcs.php

示例10: rollback

 /**
  * Rollback a transaction.
  *
  * @returns \Docnet\DB
  * @throws \Exception if we're not in a transaction
  * @throws \Exception if the driver reports that the rollback failed
  */
 public function rollback()
 {
     if (!$this->bol_in_transaction) {
         throw new \Exception("Not in a transaction, can't rollback");
     }
     if (!$this->obj_db->rollback()) {
         throw new \Exception("MySQL failed to rollback the transaction");
     }
     $this->bol_in_transaction = false;
     return $this;
 }
开发者ID:p13eater,项目名称:php-dbal,代码行数:18,代码来源:DB.php

示例11: rollback

 /**
  * Rollback
  *
  * @throws Exception\RuntimeException
  * @return $this
  */
 public function rollback()
 {
     if (!$this->resource) {
         throw new Exception\RuntimeException('Must be connected before you can rollback.');
     }
     if (!$this->inTransaction) {
         throw new Exception\RuntimeException('Must call commit() before you can rollback.');
     }
     $this->resource->rollback();
     return $this;
 }
开发者ID:huang-sh,项目名称:yaf.app,代码行数:17,代码来源:Connection.php

示例12: rollback

 public function rollback()
 {
     if ($this->transactionCount == 0) {
         return false;
     }
     if ($this->transactionCount == 1) {
         $result = @$this->mysqli->rollback();
     } else {
         $result = @$this->mysqli->query('ROLLBACK TO point' . ($this->transactionCount - 1));
     }
     $this->popTransaction();
     return $result;
 }
开发者ID:binsoul,项目名称:db-platform-mysql,代码行数:13,代码来源:DefaultConnection.php

示例13: rollback

 /**
  * {@inheritDoc}
  */
 public function rollback()
 {
     if (!$this->isConnected()) {
         throw new Exception\RuntimeException('Must be connected before you can rollback.');
     }
     if (!$this->inTransaction) {
         throw new Exception\RuntimeException('Must call beginTransaction() before you can rollback.');
     }
     $this->resource->rollback();
     $this->resource->autocommit(true);
     $this->inTransaction = false;
     return $this;
 }
开发者ID:Indigo1337,项目名称:Cooking4Dummies,代码行数:16,代码来源:Connection.php

示例14: transactionRollback

 /**
  * Method to roll back a transaction.
  *
  * @param   boolean  $toSavepoint  If true, rollback to the last savepoint.
  *
  * @return  void
  *
  * @since   1.0
  * @throws  \RuntimeException
  */
 public function transactionRollback($toSavepoint = false)
 {
     if (!$toSavepoint || $this->transactionDepth <= 1) {
         $this->connect();
         if ($this->connection->rollback()) {
             $this->transactionDepth = 0;
         }
         return;
     }
     $savepoint = 'SP_' . ($this->transactionDepth - 1);
     if ($this->executeUnpreparedQuery('ROLLBACK TO SAVEPOINT ' . $this->quoteName($savepoint))) {
         $this->transactionDepth--;
     }
 }
开发者ID:jbanety,项目名称:database,代码行数:24,代码来源:MysqliDriver.php

示例15: compraProdotto

function compraProdotto($id, $email)
{
    $mysqli = new mysqli(DB_SERVER, DB_USER, DB_PASS, DB_NAME);
    $mysqli->autocommit(false);
    $add = $mysqli->query("INSERT INTO ordini (id_prodotto, nomeutente) VALUES ({$id}, '{$email}')");
    $q = $mysqli->query("SELECT * FROM prodotti WHERE id={$id}");
    if (!$add) {
        $mysqli->rollback();
        return false;
    }
    $prodottoSelezionato = mysqli_fetch_assoc($q);
    if ($prodottoSelezionato['quantita'] == 0) {
        $mysqli->rollback();
        return false;
    }
    $nuovaQuantita = $prodottoSelezionato['quantita'] - 1;
    $u = $mysqli->query("UPDATE prodotti SET quantita = {$nuovaQuantita} WHERE id={$id}");
    if ($u) {
        $mysqli->commit();
        $mysqli->autocommit(true);
        return true;
    }
}
开发者ID:siriguismaele,项目名称:AMM2015,代码行数:23,代码来源:funzioni.php


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