mysqli::begin_transaction

mysqli_begin_transaction

(PHP 5 >= 5.5.0, PHP 7)

mysqli::begin_transaction -- mysqli_begin_transactionStarts a transaction

Açıklama

Nesne yönelimli kullanım (method):

public mysqli::begin_transaction ([ int $flags = 0 [, string $name ]] ) : bool

Yordamsal kullanım:

mysqli_begin_transaction ( mysqli $link [, int $flags = 0 [, string $name ]] ) : bool

Begins a transaction. Requires the InnoDB engine (it is enabled by default). For additional details about how MySQL transactions work, see » http://dev.mysql.com/doc/mysql/en/commit.html.

Değiştirgeler

bağlantı

Sadece yordamsal tarz: mysqli_connect() veya mysqli_init() işlevinden dönen bir bağlantı tanıtıcısı.

flags

Valid flags are:

  • MYSQLI_TRANS_START_READ_ONLY: Start the transaction as "START TRANSACTION READ ONLY". Requires MySQL 5.6 and above.

  • MYSQLI_TRANS_START_READ_WRITE: Start the transaction as "START TRANSACTION READ WRITE". Requires MySQL 5.6 and above.

  • MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT: Start the transaction as "START TRANSACTION WITH CONSISTENT SNAPSHOT".

name

Savepoint name for the transaction.

Dönen Değerler

Başarı durumunda TRUE, başarısızlık durumunda FALSE döner.

Örnekler

Örnek 1 $mysqli->begin_transaction() example

Nesne yönelimli kullanım

<?php
$mysqli 
= new mysqli("127.0.0.1""my_user""my_password""sakila");

if (
$mysqli->connect_errno) {
    
printf("Connect failed: %s\n"$mysqli->connect_error);
    exit();
}

$mysqli->begin_transaction(MYSQLI_TRANS_START_READ_ONLY);

$mysqli->query("SELECT first_name, last_name FROM actor");
$mysqli->commit();

$mysqli->close();
?>

Yordamsal kullanım

<?php
$link 
mysqli_connect("127.0.0.1""my_user""my_password""sakila");

if (
mysqli_connect_errno()) {
    
printf("Connect failed: %s\n"mysqli_connect_error());
    exit();
}

mysqli_begin_transaction($linkMYSQLI_TRANS_START_READ_ONLY);

mysqli_query($link"SELECT first_name, last_name FROM actor LIMIT 1");
mysqli_commit($link);

mysqli_close($link);
?>

Ayrıca Bakınız