0

I have a doubt and I can't find a similar question.

In a generic php script like:

$pdo->beginTransaction();
//...
//many things to do...
//...
$pdo->commit();

Let's say the user stops the page loading or loses connection before the commit is reached. Does the transaction remain opened? Do I have to try a rollback before the beginTransaction?

Suresh Kamrushi
  • 15,627
  • 13
  • 75
  • 90
the_nuts
  • 5,634
  • 1
  • 36
  • 68

1 Answers1

1

If you are worried about a user dropping connection, you would be better off using ignore_user_abort

ignore_user_abort

That way, regardless of whether a user stops the page loading or any other consequence, the script runs until completion.

Ozzy
  • 10,285
  • 26
  • 94
  • 138