本文整理汇总了PHP中mysqli_autocommit函数的典型用法代码示例。如果您正苦于以下问题:PHP mysqli_autocommit函数的具体用法?PHP mysqli_autocommit怎么用?PHP mysqli_autocommit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mysqli_autocommit函数的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
public function commit()
{
if (phpversion() < '5.5.0') {
mysqli_autocommit($this->connection, TRUE);
}
// return mysqli_autocommit($this->connection, TRUE);
mysqli_commit($this->connection);
}
示例4: connect
public function connect()
{
if ($this->link = mysqli_connect($this->host, $this->user, $this->pass)) {
$this->exception("Could not connect to the database!");
}
mysqli_select_db($this->link, $this->name);
mysqli_autocommit($this->link, false);
}
示例5: commit
public function commit()
{
if (mysqli_commit($this->conn)) {
mysqli_autocommit($this->conn, true);
} else {
throw new server_except('cannot commit transaction');
}
}
示例6: 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));
}
}
示例7: __construct
function __construct($servername, $username, $password, $database)
{
$this->con = mysqli_connect($servername, $username, $password, $database);
if (!$this->con) {
$this->error = mysqli_connect_error();
mysqli_autocommit($this->con, FALSE);
}
return $this->con;
}
示例8: bind_twice
function bind_twice($link, $engine, $sql_type1, $sql_type2, $bind_type1, $bind_type2, $bind_value1, $bind_value2, $offset)
{
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_mysqli_stmt_bind_param_type_juggling_table_1")) {
printf("[%03d + 1] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
return false;
}
mysqli_autocommit($link, true);
$sql = sprintf("CREATE TABLE test_mysqli_stmt_bind_param_type_juggling_table_1(col1 %s, col2 %s) ENGINE=%s", $sql_type1, $sql_type2, $engine);
if (!mysqli_query($link, $sql)) {
printf("[%03d + 2] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
return false;
}
if (!($stmt = mysqli_stmt_init($link))) {
printf("[%03d + 3] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
return false;
}
if (!mysqli_stmt_prepare($stmt, "INSERT INTO test_mysqli_stmt_bind_param_type_juggling_table_1(col1, col2) VALUES (?, ?)")) {
printf("[%03d + 4] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
return false;
}
if (!mysqli_stmt_bind_param($stmt, $bind_type1 . $bind_type2, $bind_value1, $bind_value1)) {
printf("[%03d + 5] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
return false;
}
if (!mysqli_stmt_execute($stmt)) {
printf("[%03d + 6] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
return false;
}
if (!mysqli_stmt_bind_param($stmt, $bind_type1 . $bind_type2, $bind_value1, $bind_value2)) {
printf("[%03d + 7] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
return false;
}
if (!mysqli_stmt_execute($stmt)) {
printf("[%03d + 8] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
return false;
}
mysqli_stmt_close($stmt);
if (!($res = mysqli_query($link, "SELECT col1, col2 FROM test_mysqli_stmt_bind_param_type_juggling_table_1"))) {
printf("[%03d + 9] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
return false;
}
if (2 !== ($tmp = mysqli_num_rows($res))) {
printf("[%03d + 10] Expecting 2 rows, got %d rows [%d] %s\n", $offset, $tmp, mysqli_errno($link), mysqli_error($link));
}
$row = mysqli_fetch_assoc($res);
if ($row['col1'] != $bind_value1 || $row['col2'] != $bind_value1) {
printf("[%03d + 11] Expecting col1 = %s, col2 = %s got col1 = %s, col2 = %s - [%d] %s\n", $offset, $bind_value1, $bind_value1, $row['col1'], $row['col2'], mysqli_errno($link), mysqli_error($link));
return false;
}
$row = mysqli_fetch_assoc($res);
if ($row['col1'] != $bind_value1 || $row['col2'] != $bind_value2) {
printf("[%03d + 12] Expecting col1 = %s, col2 = %s got col1 = %s, col2 = %s - [%d] %s\n", $offset, $bind_value1, $bind_value2, $row['col1'], $row['col2'], mysqli_errno($link), mysqli_error($link));
return false;
}
mysqli_free_result($res);
return true;
}
示例9: dbConnect
public function dbConnect()
{
$this->conn1 = @mysqli_connect($this->db_hostname, $this->db_username, $this->db_password, $this->db_name);
if (!$this->conn1) {
die(mysqli_connect_error());
}
$this->db1 = mysqli_select_db($this->conn1, $this->db_name) or die(mysqli_error($this->conn1));
mysqli_autocommit($this->conn1, TRUE);
return $this->conn1;
}
示例10: setAutoCommit
static function setAutoCommit($con, $autoCommit)
{
try {
$v = mysqli_autocommit($con, $autoCommit);
if (!$v) {
throw new Exception("Can not set commit automatically.");
}
} catch (Exception $e) {
REDLog::writeErrLog($e->getMessage());
}
}
示例11: __construct
function __construct()
{
if (!$this->conectarSGBD()) {
die("A conexão com o servidor não foi estabelecida!");
}
if (!$this->selecionarBanco()) {
die("A conexão com o servidor não foi estabelecida!");
}
if (!mysqli_autocommit($this->conexao, false)) {
die("Auto comite não ativado!");
}
}
示例12: openConn
function openConn()
{
// Create connection
$conn = mysqli_connect();
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
mysqli_autocommit($conn, FALSE);
// echo "Connected successfully <br>";
$conn->select_db("dmhweborg");
return $conn;
}
示例13: createDbConnection
function createDbConnection($host, $username, $password, $dbname, $port = null)
{
if (!$port) {
$dbConnection = mysqli_connect($host, $username, $password, $dbname);
} else {
$dbConnection = mysqli_connect($host, $username, $password, $dbname, $port);
}
if (!$dbConnection) {
die('Could not connect: ' . mysqli_connect_error());
}
$dbConnection->set_charset("utf8");
mysqli_autocommit($dbConnection, FALSE);
return $dbConnection;
}
示例14: dbNewMessage
public function dbNewMessage($email, $name, $website, $message)
{
$email = mysqli_real_escape_string($this->link, $email);
$name = mysqli_real_escape_string($this->link, $name);
$website = mysqli_real_escape_string($this->link, $website);
$message = mysqli_real_escape_string($this->link, $message);
mysqli_autocommit($this->link, FALSE);
$query = "INSERT INTO CONTACT(pk_contact,name,email,website,message) \n\t\t\t\t VALUES('NULL','{$name}','{$email}','{$website}','{$message}')";
mysqli_query($this->link, $query);
if (mysqli_errno($this->link)) {
return -1;
} else {
mysqli_commit($this->link);
return 1;
}
}
示例15: EndTransaction
public function EndTransaction()
{
if (!$this->in_transazione) {
return 0;
}
if ($this->Commit()) {
mysqli_autocommit($this->conn, true);
$this->in_transazione = false;
return 1;
} else {
$this->Rollback();
autocommit($this->conn, true);
$this->in_transazione = false;
return 0;
}
}