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


PHP mysqli_rollback函数代码示例

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


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

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

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

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

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

示例5: finalizeTransaction

 public function finalizeTransaction($transactionComplete)
 {
     if (!$transactionComplete) {
         mysqli_rollback($this->dbConnection);
     } else {
         mysqli_commit($this->dbConnection);
     }
 }
开发者ID:lahirwisada,项目名称:orangehrm,代码行数:8,代码来源:UpgradeUtility.php

示例6: Rollback

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

示例7: rollback

 public function rollback()
 {
     if (mysqli_rollback($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

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

示例9: _rollback

 /**
  * DB transaction rollback
  * this method is private
  * @return boolean
  */
 function _rollback($transactionLevel = 0)
 {
     $connection = $this->_getConnection('master');
     $point = $transactionLevel - 1;
     if ($point) {
         $this->_query("ROLLBACK TO SP" . $point, $connection);
     } else {
         mysqli_rollback($connection);
         $this->setQueryLog(array('query' => 'ROLLBACK'));
     }
     return true;
 }
开发者ID:rhymix,项目名称:rhymix,代码行数:17,代码来源:DBMysqli_innodb.class.php

示例10: commandDataBase

 function commandDataBase($sql)
 {
     $conn = new mysqli($this->servername, $this->username, $this->password, $this->dbname);
     if ($conn->connect_error) {
         die('Connection failed: ' . $conn->connect_error);
     }
     mysqli_autocommit($conn, FALSE);
     if ($conn->query($sql) === TRUE) {
         mysqli_commit($conn);
         return true;
     } else {
         mysqli_rollback($conn);
         return false;
     }
     $conn->close();
 }
开发者ID:schnurli13,项目名称:Storytelling,代码行数:16,代码来源:mysqlModule.php

示例11: updateRecord

function updateRecord($arrayValues, $table, $condition, $autoCommit = "yes")
{
    include_once 'connection.php';
    mysqli_autocommit($conn, false);
    $table_value = "";
    if (empty($arrayValues)) {
        echo "Incomplete Parameters Passed";
        die;
    }
    if (!is_array($arrayValues)) {
        echo "Parameter Passed is not an Array";
        return false;
    }
    foreach ($arrayValues as $ind => $v) {
        //$table_value .= $ind . "= '" . $v . "',";
        $firstChar = substr($v, 0, 1);
        if ($firstChar == '(') {
            $table_value .= $ind . "= " . $v . ",";
        } else {
            $table_value .= $ind . "= '" . $v . "',";
        }
    }
    $table_value = substr($table_value, 0, -1);
    try {
        $sql = "UPDATE {$table} SET {$table_value} WHERE {$condition}";
        //Check if inserted to table, if not rollback
        mysqli_query($conn, $sql);
        if (mysqli_errno($conn)) {
            $errno = mysqli_errno($conn);
            mysqli_rollback($conn);
            return "error";
        } else {
            if ($autoCommit == "yes") {
                mysqli_commit($conn);
                return true;
            } else {
                return true;
            }
        }
    } catch (Exception $e) {
        mysqli_rollback($conn);
        return "error";
    }
}
开发者ID:jimmarv,项目名称:comparch,代码行数:44,代码来源:save_instructions.php

示例12: _sql_transaction

 /**
  * SQL Transaction
  * @access private
  */
 function _sql_transaction($status = 'begin')
 {
     switch ($status) {
         case 'begin':
             return @mysqli_autocommit($this->db_connect_id, false);
             break;
         case 'commit':
             $result = @mysqli_commit($this->db_connect_id);
             @mysqli_autocommit($this->db_connect_id, true);
             return $result;
             break;
         case 'rollback':
             $result = @mysqli_rollback($this->db_connect_id);
             @mysqli_autocommit($this->db_connect_id, true);
             return $result;
             break;
     }
     return true;
 }
开发者ID:jambik,项目名称:elenaburgon,代码行数:23,代码来源:mysqli.php

示例13: executeMultiNoresSQL

 /**
  * Transaction style - runs queries in order
  *
  * @since 08.05.2011
  * Refactored for using $this::mysqli_connection instead of mysqli_init/mysqli_close
  */
 public function executeMultiNoresSQL(&$queryArry)
 {
     $link = $this->getMysqliConnection();
     /* set autocommit to off */
     mysqli_autocommit($link, FALSE);
     $all_query_ok = true;
     //do queries
     foreach ($queryArry as $query) {
         if (!mysqli_real_query($link, $query)) {
             $all_query_ok = false;
         }
     }
     if ($all_query_ok) {
         /* commit queries */
         mysqli_commit($link);
     } else {
         /* Rollback */
         mysqli_rollback($link);
     }
     /* set autocommit to on */
     mysqli_autocommit($link, TRUE);
     return $all_query_ok;
 }
开发者ID:sergrin,项目名称:crawlers-il,代码行数:29,代码来源:DBAdapter2.class.php

示例14: insertUnits

 public function insertUnits(Units $units)
 {
     $con = self::openConnection();
     $affected = 0;
     mysqli_begin_transaction($con);
     $stm = mysqli_stmt_init($con);
     $sql = "INSERT INTO currency (code) VALUE (?)";
     mysqli_stmt_prepare($stm, $sql);
     foreach ($units->getUnits() as $unit) {
         $code = $unit->getCode();
         mysqli_stmt_bind_param($stm, 's', $code);
         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,代码行数:23,代码来源:CurrencyDAO.php

示例15: salvarCliente

 public function salvarCliente($cliente, $endereco)
 {
     $nome = $cliente->getNome();
     $fone = $cliente->getFone();
     $email = $cliente->getEmail();
     $instagran = $cliente->getInstagran();
     $indicacao = $cliente->getIndicacao();
     $tipo = $cliente->getTipo();
     $whatsapp = $cliente->getWhatsapp();
     $aniversario = $cliente->getAniversario();
     $facebook = $cliente->getFacebook();
     //$endereco = new Endereco();
     $logradouro = $endereco->getLogradouro();
     $numero = $endereco->getNumero();
     $bairro = $endereco->getBairro();
     $cidade = $endereco->getCidade();
     $estado = $endereco->getEstado();
     $cep = $endereco->getCep();
     $complemento = $endereco->getComplemento();
     /*
      * conecta o banco de dados
      */
     $con = new JqsConnectionFactory();
     $link = $con->conectar();
     $query = "INSERT INTO tb_clientes (nome_cliente, fone_cliente, email_cliente, instagran_cliente, indicacao_cliente, tipo_cliente, whatsapp_cliente, aniversario_cliente, facebook_cliente) \n\t\tvalues('{$nome}', '{$fone}', '{$email}', '{$instagran}', '{$indicacao}', '{$tipo}', '{$whatsapp}', '{$aniversario}', '{$facebook}')";
     $query2 = "INSERT INTO tb_enderecos (logradouro_endereco, numero_endereco, bairro_edereco, cidade_endereco, \n\t\testado_endereco, cep_endereco, complemento_endereco, id_cliente_endereco) values('{$logradouro}','{$numero}',\n\t\t'{$bairro}', '{$cidade}', '{$estado}', '{$cep}', '{$complemento}', last_insert_id())";
     try {
         mysqli_autocommit($link, FALSE);
         mysqli_query($link, $query) or die(mysqli_error($link) . "cliente");
         mysqli_query($link, $query2) or die(mysqli_error($link) . "endereço");
         mysqli_commit($link);
         mysqli_autocommit($link, TRUE);
     } catch (Exception $e) {
         mysqli_rollback($link);
         echo $e;
     }
 }
开发者ID:jaquesoliveira,项目名称:preciata-gh,代码行数:37,代码来源:ClienteDao.php


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