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


PHP mysqli_commit函数代码示例

本文整理汇总了PHP中mysqli_commit函数的典型用法代码示例。如果您正苦于以下问题:PHP mysqli_commit函数的具体用法?PHP mysqli_commit怎么用?PHP mysqli_commit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: salvarProduto

 public function salvarProduto($produto, $preco)
 {
     $codigo = $produto->getCodigo();
     $nome = $produto->getNome();
     $descricao = $produto->getDescricao();
     $imagem = $produto->getUrlImagem();
     $compra = $preco->getCompra();
     $venda = $preco->getVenda();
     $revenda = $preco->getReVenda();
     /*
      * conecta o banco de dados
      */
     $con = new JqsConnectionFactory();
     $link = $con->conectar();
     $query = "INSERT INTO tb_produtos (codigo_produto, nome_produto, descricao_produto, url_imagem) \n\t\tvalues('{$codigo}', '{$nome}', '{$descricao}', '{$imagem}')";
     $query2 = "INSERT INTO tb_precos (preco_compra, preco_venda, preco_revenda, id_produto_preco) \n\t\tvalues('{$compra}', '{$venda}', '{$revenda}', last_insert_id() )";
     try {
         mysqli_autocommit($link, FALSE);
         mysqli_query($link, $query) or die(mysqli_error($link) . "Produto");
         mysqli_query($link, $query2) or die(mysqli_error($link) . "Preço");
         mysqli_commit($link);
         mysqli_autocommit($link, TRUE);
     } catch (Exception $e) {
         mysqli_rollback($link);
         echo $e;
     }
 }
开发者ID:jaquesoliveira,项目名称:preciata-gh,代码行数:27,代码来源:ProdutoDao.php

示例2: sql_transaction

 function sql_transaction($status = 'begin')
 {
     switch ($status) {
         case 'begin':
             $result = @mysqli_autocommit($this->db_connect_id, false);
             $this->transaction = true;
             break;
         case 'commit':
             $result = @mysqli_commit($this->db_connect_id);
             @mysqli_autocommit($this->db_connect_id, true);
             $this->transaction = false;
             if (!$result) {
                 @mysqli_rollback($this->db_connect_id);
                 @mysqli_autocommit($this->db_connect_id, true);
             }
             break;
         case 'rollback':
             $result = @mysqli_rollback($this->db_connect_id);
             @mysqli_autocommit($this->db_connect_id, true);
             $this->transaction = false;
             break;
         default:
             $result = true;
     }
     return $result;
 }
开发者ID:kidwellj,项目名称:scuttle,代码行数:26,代码来源:mysqli.php

示例3: _commit

 /**
  * DB transaction commit
  * this method is private
  * @return boolean
  */
 function _commit()
 {
     $connection = $this->_getConnection('master');
     mysqli_commit($connection);
     $this->setQueryLog(array('query' => 'COMMIT'));
     return true;
 }
开发者ID:rhymix,项目名称:rhymix,代码行数:12,代码来源:DBMysqli_innodb.class.php

示例4: commit

 public function commit()
 {
     if (!\mysqli_commit($this->connection)) {
         throw new \Exception('Could not start Transaction: ' . \mysqli_error($this->connection));
     }
     return true;
 }
开发者ID:webcraftmedia,项目名称:system,代码行数:7,代码来源:ConnectionMYS.php

示例5: updateInformation

function updateInformation($sql, $conn)
{
    global $gpa, $degree, $school, $graduationDate, $resumeID, $additionalInfomation, $status, $resumeUserID;
    try {
        // Connect to database
        if ($sql == "create") {
            $userCreateSQL = "INSERT INTO Resume_Post (gpa,degree,school,graduationDate,resumeID,additionalInfomation,userID,status) VALUES (?,?,?,STR_TO_DATE( ? , '%Y-%m-%d'),?,?,?,?)";
            $stmt = $conn->prepare($userCreateSQL);
            $stmt->bind_param('ssssssss', $gpa, $degree, $school, $graduationDate, $resumeID, $additionalInfomation, $resumeUserID, $status);
        } else {
            $userUpdateSQL = "UPDATE Resume_Post SET  gpa= ? , degree= ? , school= ?, graduationDate = STR_TO_DATE( ? , '%Y-%m-%d'), resumeID= ?, additionalInfomation= ?, status= ? WHERE resumeID= ? AND userID= ? ";
            $stmt = $conn->prepare($userUpdateSQL);
            $stmt->bind_param('sssssssss', $gpa, $degree, $school, $graduationDate, $resumeID, $additionalInfomation, $status, $resumeID, $resumeUserID);
        }
        //$sql = "UPDATE Resume_Post SET  gpa= 3.96 , degree= 'bachelor' , school= 'UT', graduationDate = STR_TO_DATE( '2015-12-12' , '%Y-%m-%d'), resumeID= 2, additionalInfomation= 'No much', status= 1 WHERE resumeID= 2 AND userID= 'meng.da'";
        //$conn->query($sql);
        // Execute and Check Errors
        $stmt->execute();
        $err = $stmt->error;
        if ($err) {
            $conn->rollback();
            $error_msg = "Some unknown database error occurred. Please inform database administrator with these error messages.<br>\nError message : " . $err . "<br>";
            echo $error_msg;
            return 0;
        } else {
            // Commit transaction
            mysqli_commit($conn);
            return 1;
        }
    } catch (mysqli_sql_exception $e) {
        echo $e->__toString();
    }
}
开发者ID:dm37537,项目名称:Career-Matcher,代码行数:33,代码来源:Resume.php

示例6: insertItems

 public function insertItems(Items $items)
 {
     $con = self::openConnection();
     $affected = 0;
     mysqli_begin_transaction($con);
     $stm = mysqli_stmt_init($con);
     $sql = "INSERT INTO category VALUES (?, ?, ?)";
     mysqli_stmt_prepare($stm, $sql);
     foreach ($items->getItems() as $item) {
         $code = $item->getCode();
         $name = $item->getName();
         $parent = $item->getParent() == null ? null : $item->getParent()->getCode();
         mysqli_stmt_bind_param($stm, 'sss', $code, $name, $parent);
         mysqli_stmt_execute($stm);
         if (mysqli_affected_rows($con) == 1) {
             $affected++;
         }
     }
     if ($affected > 0) {
         mysqli_commit($con);
     } else {
         mysqli_rollback($con);
     }
     return $affected;
 }
开发者ID:Voww,项目名称:PHP_test_tasks,代码行数:25,代码来源:CategoryDAO.php

示例7: insertItems

 public function insertItems(Items $items)
 {
     $con = self::openConnection();
     $affected = 0;
     mysqli_begin_transaction($con);
     $stm = mysqli_stmt_init($con);
     $sql = "INSERT INTO product VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
     mysqli_stmt_prepare($stm, $sql);
     foreach ($items->getItems() as $item) {
         $code = $item->getCode();
         $articul = $item->getArticul();
         $name = $item->getName();
         $bmuID = $item->getBasicMeasurementUnit() == null ? null : $item->getBasicMeasurementUnit()->getId();
         $price = $item->getPrice();
         $curID = $item->getCurrency() == null ? null : $item->getCurrency()->getId();
         $muID = $item->getMeasurementUnit() == null ? null : $item->getMeasurementUnit()->getId();
         $parent = $item->getParent() == null ? null : $item->getParent()->getCode();
         mysqli_stmt_bind_param($stm, 'sssdddds', $code, $articul, $name, $bmuID, $price, $curID, $muID, $parent);
         mysqli_stmt_execute($stm);
         if (mysqli_affected_rows($con) == 1) {
             $affected++;
         }
     }
     if ($affected > 0) {
         mysqli_commit($con);
     } else {
         mysqli_rollback($con);
     }
     return $affected;
 }
开发者ID:Voww,项目名称:PHP_test_tasks,代码行数:30,代码来源:ProductDAO.php

示例8: commit

 public function commit()
 {
     if (phpversion() < '5.5.0') {
         mysqli_autocommit($this->connection, TRUE);
     }
     // return mysqli_autocommit($this->connection, TRUE);
     mysqli_commit($this->connection);
 }
开发者ID:songfarm-david,项目名称:Songfarm,代码行数:8,代码来源:database.php

示例9: commit

 public function commit()
 {
     if (mysqli_commit($this->connection)) {
         mysqli_autocommit($this->connection, $this->autoCommit = true);
     } else {
         throw new Sabel_Db_Exception_Driver(mysql_error($this->connection));
     }
 }
开发者ID:reoring,项目名称:sabel,代码行数:8,代码来源:Driver.php

示例10: commit

 public function commit()
 {
     if (mysqli_commit($this->conn)) {
         mysqli_autocommit($this->conn, true);
     } else {
         throw new server_except('cannot commit transaction');
     }
 }
开发者ID:xpd1437,项目名称:swap,代码行数:8,代码来源:mysql_rdb.php

示例11: Commit

 public function Commit()
 {
     if ($this->in_transazione) {
         return mysqli_commit($this->conn);
     } else {
         return 0;
     }
 }
开发者ID:AlbertoArdu,项目名称:DistributedProgrammingExercises,代码行数:8,代码来源:ClassDB.php

示例12: commit

 public function commit()
 {
     parent::commit();
     if (!mysqli_commit($this->link)) {
         $this->set_driver_error(null, PDO::ERRMODE_EXCEPTION, 'commit');
     }
     $this->setAttribute(PDO::ATTR_AUTOCOMMIT, 1);
     return true;
 }
开发者ID:Deepab23,项目名称:clinic,代码行数:9,代码来源:mysqli.php

示例13: commit

 static function commit($con)
 {
     try {
         $v = mysqli_commit($con);
         if (!$v) {
             throw new Exception("Error commit to database.");
         }
     } catch (Exception $e) {
         REDLog::writeErrLog($e->getMessage());
     }
 }
开发者ID:Taruca,项目名称:lib,代码行数:11,代码来源:DatabaseManager.php

示例14: encerraTransacao

 public function encerraTransacao($lErro)
 {
     $this->lTransacao = false;
     if ($lErro) {
         $lRetorno = mysqli_rollback($this->conn);
     } else {
         $lRetorno = mysqli_commit($this->conn);
     }
     $this->fecharConexao();
     return $lRetorno;
 }
开发者ID:ricardosander,项目名称:petshop,代码行数:11,代码来源:MySQL.php

示例15: query

 function query($query, &$output)
 {
     $output = array();
     $result = @mysqli_query($this->link, $query);
     if (!$result) {
         return FALSE;
     }
     if ($result !== TRUE) {
         while ($row = mysqli_fetch_array($result)) {
             $output[] = $row;
         }
     }
     mysqli_commit($this->link);
     return $output;
 }
开发者ID:robertbanh,项目名称:mrmilestone,代码行数:15,代码来源:db.php


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