Ignoring browser commands

I have rarely encountered such situation, but for larger projects it is certainly common problem. Assume that the script performs some queries in the database (deleting / adding / editing) and during these user presses the Stop button in your browser. By this command php script completes its work, which in our case may be fraught with violations of the integrity of the database.

This problem is resolved by function ignore_user_abort ():

ignore_user_abort (true);

… Is executed queries to the database …

ignore_user_abort (false);

Original source: http://i-novice.net/poleznye-php-tryuki/

Note: Best solution for such problems is using transaction on databases :)

Facebook comments:

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">