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