mysqli::begin_transaction
mysqli::begin_transaction
mysqli_begin_transaction
(PHP 5 >= 5.5.0, PHP 7)
mysqli :: begin_transaction - mysqli_begin_transaction - 启动一个事务
Description
面向对象的风格(方法):
public bool mysqli::begin_transaction ([ int $flags [, string $name ]] )
程序风格:
bool mysqli_begin_transaction ( mysqli $link [, int $flags [, string $name ]] )
开始交易。需要MySQL 5.6及更高版本,以及InnoDB引擎(默认启用)。
Parameters
`link`
仅过程样式:由mysqli_connect()或mysqli_init()返回的链接标识符
flags
有效的标志是:
MYSQLI_TRANS_START_READ_ONLY
:以“START TRANSACTION READ ONLY”开始处理。
MYSQLI_TRANS_START_READ_WRITE
:以“START TRANSACTION READ WRITE”开始处理。
MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT:以“使用一致性快照开始交易”开始交易。name交易的保存点名称。返回值TRUE成功或FALSE失败时返回。 ExamplesExample #1 $mysqli->begin_transaction() exampleObject oriented style<?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( ?>Procedural style<?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($link, MYSQLI_TRANS_START_READ_ONLY mysqli_query($link, "SELECT first_name, last_name FROM actor LIMIT 1" mysqli_commit($link mysqli_close($link ?>
© 1997–2017 The PHP Documentation Group
根据知识共享署名许可证v3.0或更高版本授权。