mysqli::begin_transaction

mysqli_begin_transaction

(PHP 5 >= 5.5.0)

mysqli::begin_transaction -- mysqli_begin_transactionStarts a transaction

Описание

Объектно-ориентированный стиль (method):

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

Процедурный стиль:

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

Внимание

К настоящему времени эта функция еще не была документирована; для ознакомления доступен только список аргументов.

Список параметров

link

Только для процедурного стиля: Идентификатор соединения, полученный с помощью mysqli_connect() или mysqli_init()

flags

name

Возвращаемые значения

Возвращает TRUE в случае успешного завершения или FALSE в случае возникновения ошибки.

Смотрите также

  • mysqli_autocommit() - Включает или отключает автоматическую фиксацию изменений базы данных
  • mysqli_commit() - Фиксирует текущую транзакцию
  • mysqli_rollback() - Откат текущей транзакции

Коментарии

Автор:
For PHP<5.5:

    mysqli_query($db, "START TRANSACTION");
2016-09-20 05:28:27
http://php5.kiev.ua/manual/ru/mysqli.begin-transaction.html
Автор:
If you receive errors like: "This server version doesn't support 'READ WRITE' and 'READ ONLY'. Minimum 5.6.5 is required" with versions of MariaDB that DO support them, this is due to an internal check in mysqli conflicting with a hack in MariaDB to allow replication with oracle mysql.

MariaDB prefixes its server version numbers with "5.5.5-" for example "5.5.5-10.3.7-MariaDB-1:10.3.7+maria~stretch". This is because oracle mysql would interpet the "10" as version 1. Mysql clients aware of MariaDB have been updated to detect and strip this prefix.

However the check for mysqli.begin-transaction sees the 5.5.5 prefix and so fails.

The workaround is to specify a custom version string without the prefix for MariaDB on the command line using the --version option. Then mysqli.begin-transaction functions as expected.
2018-05-29 20:44:33
http://php5.kiev.ua/manual/ru/mysqli.begin-transaction.html
Автор:
The above answer from Ral worked for us, Thanks a lot. This is how we implemented the proposed workaround for 

Warning: mysqli_begin_transaction(): This server version doesn't support 'READ WRITE' and 'READ ONLY'. Minimum 5.6.5 is required

We appended the following line to /etc/my.cnf and restarted MySQL server

version=10.2.19-MariaDB
2018-12-15 05:25:41
http://php5.kiev.ua/manual/ru/mysqli.begin-transaction.html
Автор:
MySQL 5.6 introduces READ ONLY mode which applies optimizations to your transactions that can only be applied when it knows in advance that no table modifications will be made and that no locks will be issued.

The default access mode is READ WRITE in all versions up to and including MySQL 5.6. Starting in MySQL 5.7, the appropriate access mode is detected automatically. So if your transaction attempts modifications or table locks, it will automatically use READ WRITE mode, otherwise it will use READ ONLY mode and your transaction will benefit from the optimizations that come from that without having to explicitly declare is as READ ONLY.

Therefore the only time you need to explicitly declare an access mode is when you are using MySQL 5.6 and you are sure that you want READ ONLY mode. Note that any queries that attempt to modify tables or issue locks in READ ONLY mode will fail. Temporary tables can still be modified.

(Moderators. This post should replace the previous post that I made on the subject. Thanks.)
2020-04-04 20:36:40
http://php5.kiev.ua/manual/ru/mysqli.begin-transaction.html

    Поддержать сайт на родительском проекте КГБ