There is this situation:
Say the user wants to shutdown the computer, is there any way to detect this in PHP? So the user goes to Start > Shutdown.
If not, is there an easy way to be sure that there will be no problems with the script? (Like a shutdown between two queries that are both for the same object?)
register_shutdown_function() seems to be the one you are looking for. However, if the OS kills the script, before the shutdown code is completely executed, you cannot do anything from within the script.
If not, is there an easy way to be sure that there will be no problems with the script? (Like a shutdown between two queries that are both for the same object?)
Transactions, but they only ensure, that the data is not corrupted, not that the data is really written.
My advice here: Use a dedicated system.