• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP mysqli_rollback函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: executeMultiNoresSQL

 public function executeMultiNoresSQL(&$queryArry)
 {
     $link = mysqli_init();
     if (!$link) {
         throw new DBAdapter2Exception("mysqli_init failed");
     }
     if (!mysqli_options($link, MYSQLI_OPT_CONNECT_TIMEOUT, 5)) {
         throw new DBAdapter2Exception("Setting MYSQLI_OPT_CONNECT_TIMEOUT failed");
     }
     if (!mysqli_real_connect($link, $this->host, $this->username, $this->password, $this->schema)) {
         throw new DBAdapter2Exception('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
     }
     if (!mysqli_set_charset($link, $this->charset)) {
         throw new DBAdapter2Exception('Error loading character set ' . $this->charset . ' - ' . mysqli_error($link));
     }
     /* 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);
     mysqli_close($link);
     return $all_query_ok;
 }
开发者ID:sergrin,项目名称:crawlers-il,代码行数:36,代码来源:DBAdapter2.class.php


示例17: rollback

 public static function rollback()
 {
     return mysqli_rollback(self::$conn);
 }
开发者ID:jackyxie,项目名称:phpspider,代码行数:4,代码来源:db.php


示例18: mysqli_stmt_execute

        $qty = $item['quantity'];
        $price = $item['price'];
        mysqli_stmt_execute($stmt);
        $affected += mysqli_stmt_affected_rows($stmt);
    }
    // Close this prepared statement:
    mysqli_stmt_close($stmt);
    // Report on the success....
    if ($affected == count($_SESSION['cart'])) {
        // Whohoo!
        // Commit the transaction:
        mysqli_commit($dbc);
        // Clear the cart:
        unset($_SESSION['cart']);
        // Message to the customer:
        echo '<p>Thank you for your order. You will be notified when the items ship.</p>';
        // Send emails and do whatever else.
    } else {
        // Rollback and report the problem.
        mysqli_rollback($dbc);
        echo '<p>Your order could not be processed due to a system error. You will be contacted in order to have the problem fixed. We apologize for the inconvenience.</p>';
        // Send the order information to the administrator.
    }
} else {
    // Rollback and report the problem.
    mysqli_rollback($dbc);
    echo '<p>Your order could not be processed due to a system error. You will be contacted in order to have the problem fixed. We apologize for the inconvenience.</p>';
    // Send the order information to the administrator.
}
mysqli_close($dbc);
include 'includes/footer.html';
开发者ID:raynaldmo,项目名称:php-education,代码行数:31,代码来源:checkout.php


示例19: CrearUsuario

 public function CrearUsuario($nombreU, $contraU, $programaU, $descPU)
 {
     // Valido si ya existe ese programa //
     $cadenaConsulta = "SELECT * from programas where nombre='" . utf8_decode($programaU) . "'";
     $repetido = $this->validarRepetido($cadenaConsulta);
     if ($repetido) {
         return json_encode(new Respuesta("ERROR", "REPETIDO PROGRAMA"));
     } else {
         // Valido si ya existe ese usuario //
         $existeUsuario = $this->validarNombreUsuario($nombreU);
         $numFilas = mysql_num_rows($existeUsuario);
         if ($numFilas > 0) {
             return json_encode(new Respuesta("ERROR", "REPETIDO USUARIO"));
         } else {
             try {
                 $this->conectarTran();
                 mysqli_autocommit($this->db_conexionTran, false);
                 $flag = true;
                 // Creo Usuario //
                 $cadenaInsertar = "Insert into usuarios (nombre, contraseña,activo,categoria) values ('" . $nombreU . "','" . $contraU . "',1,2)";
                 $flag = mysqli_query($this->db_conexionTran, $cadenaInsertar);
                 if (!$flag) {
                     mysqli_rollback($this->db_conexionTran);
                     throw new Exception('Error MySQL');
                 } else {
                     // Creo programa //
                     $cadenaInsertar = "Insert into programas (id, nombre, descripcion,activo,usuario) values ( '','" . utf8_decode($programaU) . "','" . utf8_decode($descPU) . "',1,'" . $nombreU . "')";
                     $flag = mysqli_query($this->db_conexionTran, $cadenaInsertar);
                     if (!$flag) {
                         mysqli_rollback($this->db_conexionTran);
                         throw new Exception('Error MySQL');
                     } else {
                         mysqli_commit($this->db_conexionTran);
                         return json_encode(new Respuesta("OK", ""));
                     }
                 }
             } catch (exception $e) {
                 throw new Exception('Error MySQL');
             }
         }
     }
 }
开发者ID:eljec,项目名称:smartvote,代码行数:42,代码来源:SmartVoteDB.php


示例20: error_reporting

    error_reporting(-1);
    mysqli_autocommit($db, false);
    $errorstr = "";
    $status = true;
    $studentgroupstodelete = array();
    if (isset($_POST['studentgroupstodelete'])) {
        $studentgroupstodelete = $_POST['studentgroupstodelete'];
    }
    $query = "delete from groups_students where groupid=";
    foreach ($studentgroupstodelete as $groupid) {
        $groupid = strip_tags(mysqli_real_escape_string($db, $groupid));
        $res = mysqli_query($db, $query . "'{$groupid}'");
        //	echo $query.$groupid;
        if (!$res) {
            $status = false;
            $errorstr = "Error in delete query";
            goto end;
        }
    }
    end:
    if ($status) {
        mysqli_commit($db);
        mysqli_close($db);
        header("Location: ./../view_studentgroups.php?prev=done&msg=Student groups deleted successfully");
    } else {
        mysqli_rollback($db);
        mysqli_close($db);
        //	echo "$errorstr";
        header("Location: ./../view_studentgroups.php?prev=fail&error=Couldn't delete student groups: {$errorstr}");
    }
}
开发者ID:vatsal-sodha,项目名称:ByteJudge,代码行数:31,代码来源:deletestudentgroups.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP mysqli_select_db函数代码示例发布时间:2022-05-15
下一篇:
PHP mysqli_result函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap