本文整理汇总了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;
}
}
示例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;
}
示例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;
}
示例4: commit
public function commit()
{
if (!\mysqli_commit($this->connection)) {
throw new \Exception('Could not start Transaction: ' . \mysqli_error($this->connection));
}
return true;
}
示例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();
}
}
示例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;
}
示例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;
}
示例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);
}
示例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));
}
}
示例10: commit
public function commit()
{
if (mysqli_commit($this->conn)) {
mysqli_autocommit($this->conn, true);
} else {
throw new server_except('cannot commit transaction');
}
}
示例11: Commit
public function Commit()
{
if ($this->in_transazione) {
return mysqli_commit($this->conn);
} else {
return 0;
}
}
示例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;
}
示例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());
}
}
示例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;
}
示例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;
}