本文整理汇总了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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例5: finalizeTransaction
public function finalizeTransaction($transactionComplete)
{
if (!$transactionComplete) {
mysqli_rollback($this->dbConnection);
} else {
mysqli_commit($this->dbConnection);
}
}
示例6: Rollback
public function Rollback()
{
if ($this->in_transazione) {
return mysqli_rollback($this->conn);
} else {
return 0;
}
}
示例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));
}
}
示例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;
}
示例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;
}
示例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();
}
示例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";
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}