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


PHP mysqli::commit方法代码示例

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


在下文中一共展示了mysqli::commit方法的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: commit

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

示例3: 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

示例4: 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

示例5: commit

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

示例6: commit

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

示例7: commit

 /**
  * Commit
  */
 public function commit()
 {
     if (!$this->resource) {
         $this->connect();
     }
     $this->resource->commit();
     $this->inTransaction = false;
 }
开发者ID:brikou,项目名称:zend_db,代码行数:11,代码来源:Connection.php

示例8: commit

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

示例9: commit

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

示例10: commit

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

示例11: commit

 /**
  * {@inheritDoc}
  */
 public function commit()
 {
     if (!$this->isConnected()) {
         $this->connect();
     }
     $this->resource->commit();
     $this->inTransaction = false;
     $this->resource->autocommit(true);
     return $this;
 }
开发者ID:Indigo1337,项目名称:Cooking4Dummies,代码行数:13,代码来源:Connection.php

示例12: transactionCommit

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

示例13: commit

 /**
  * Commit a transaction. If we're not in transaction, throw an exception.
  * It's important that the calling code knows it's not in a transaction if
  * the developer assumed that they were.
  *
  * @todo Are we scared that bol_in_transaction might get out of sync and
  * prevent legit commits?
  *
  * @return \Docnet\DB
  * @throws \Exception if we're not in a transaction
  * @throws \Exception if the driver reports that the commit failed
  */
 public function commit()
 {
     if (!$this->bol_in_transaction) {
         throw new \Exception("Not in a transaction, can't commit");
     }
     if (!$this->obj_db->commit()) {
         throw new \Exception("MySQL failed to commit the transaction");
     }
     $this->bol_in_transaction = false;
     return $this;
 }
开发者ID:p13eater,项目名称:php-dbal,代码行数:23,代码来源:DB.php

示例14: commit

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

示例15: db_insert

function db_insert($insert_query)
{
    // Instantiate the mysqli class
    $mysqli = new mysqli();
    //Provide your DB credentials here
    // Connect to the database server and select a database
    $mysqli->connect('your db server', 'your db id', 'your password', 'your db name');
    //Execute query
    $result = $mysqli->query($insert_query);
    //commit
    $commit = $mysqli->commit();
    // Close the connection
    $mysqli->close();
}
开发者ID:nawendu,项目名称:Facebook-Data-Extraction-Basic,代码行数:14,代码来源:get_friends_list.php


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