Hướng dẫn start transaction php

mysqli_begin_transaction

[PHP 5 >= 5.5.0, PHP 7, PHP 8]

mysqli::begin_transaction -- mysqli_begin_transactionStarts a transaction

Description

Object-oriented style

public mysqli::begin_transaction[int $flags = 0, ?string $name = null]: bool

mysqli_begin_transaction[mysqli $mysql, int $flags = 0, ?string $name = null]: bool

Parameters

mysql

Procedural style only: A mysqli object returned by mysqli_connect[] or mysqli_init[]

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.

Return Values

Returns true on success or false on failure.

Changelog

VersionDescription
8.0.0 name is now nullable.

Examples

Example #1 mysqli::begin_transaction[] example

Object-oriented style

Chủ Đề