Penggunaan fungsi ROLLBACK pada PHP

mysqli_rollback

[PHP 5, PHP 7, PHP 8]

mysqli::rollback -- mysqli_rollbackRolls back current transaction

Description

Object-oriented style

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

mysqli_rollback[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

A bitmask of MYSQLI_TRANS_COR_* constants.

name

If provided then ROLLBACK/*name*/ is executed.

Return Values

Returns true on success or false on failure.

Changelog

VersionDescription
8.0.0 name is now nullable.

Notes

Note:

This function does not work with non transactional table types [like MyISAM or ISAM].

See Also

  • mysqli_begin_transaction[] - Starts a transaction
  • mysqli_commit[] - Commits the current transaction
  • mysqli_autocommit[] - Turns on or off auto-committing database modifications
  • mysqli_release_savepoint[] - Removes the named savepoint from the set of savepoints of the current transaction

Steven McCoy

10 years ago

Remember that MyISAM tables do not support rollbacks.

I just drove myself crazy for an afternoon trying to figure out what was wrong with my code - meanwhile it was fine all along

Lorenzo - webmaster AT 4tour DOT it

13 years ago

This is an example to explain the powerful of the rollback and commit functions.
Let's suppose you want to be sure that all queries have to be executed without errors before writing data on the database.
Here's the code:

Bài mới nhất

Chủ Đề