2

I have searched through several answers but cannot find what I need.

I want to use transactions with mysqli. Ive seen that most examples use $mysqli->autocommit(false);. Would using $mysqli->begin_transaction(); have the same effect as turning the autocommit off? When I commit will it automatically be turned back on? Lastly why can I not use something similar to below:

$sql = ('
    START TRANSACTION;

    SELECT
    ...
');

I plan to combine my transactions with prepared statements.

FamousAv8er
  • 2,345
  • 2
  • 9
  • 27
  • 1
    Does that answer your question? https://stackoverflow.com/a/42629072/1839439 – Dharman Dec 18 '19 at 18:22
  • @Dharman yes thank you! – FamousAv8er Dec 18 '19 at 18:24
  • 1
    You could also take a look at [What is the benefit of using “begin_transaction” method in MySQLi?](https://stackoverflow.com/questions/48812724/what-is-the-benefit-of-using-begin-transaction-method-in-mysqli) – Dharman Dec 18 '19 at 19:54

0 Answers0