View Full Version : A Strange problem- Need solution
07-09-2005, 12:35 PM
Suppose, i am giving entry in an table and data is stored first at parent table column then at chilld table column. This is all done through my PHP code.
Suppose, one entry of data is written in parent table, but at once, server is struked or electricity is gone and due to any of these conditions, data cannot be written in child table.
This is the main problem
What is the problem, can i make a exceptional handling or what can i do.
what is the better solution to be make in a program
07-09-2005, 12:50 PM
server is struked or electricity is gone and due to any of these conditions, data cannot be written in child table.
maybe you need a back-up power supply for your computer? :cool:
No, seriously, I can't understand what the problem is....could you be more clear?
Include some code....
07-09-2005, 12:54 PM
power supply and server strucked are just examples. I want to say that data is entered in parent table, but due to any problem cannot be inserted into child table.
And this is a bug, because data is inserted only in one table instead of two
Hope you understand.
what can we do in our software.
07-09-2005, 01:00 PM
I suppose it depends how you have your tables set up and what your code is meant to be doing. If you know that there will definitely be a child entry for the parent table and the server goes down after the parent is written but before the child is written (you'd have to be VERY unlucky I guess but it may happen), then the only way to handle this would be to have your script scan the database for parent entries without corresponding child entries and flag those or remove them as appropriate.
Anything more advanced would surely require backup data being written to the database, and you're back to square one then because the server might go down during the backup data being written.
It all depends how you want to handle the whole thing. I suppose another way is to have a field "process_complete" and a timestamp for when the record was created or modified. When you create a record you insert the timestamp but leave process_complete blank and only make an entry for this field after everything else in the script that needed to be done was completed successfully. Then your script regularly checks for records that are not marked as complete and have a timestamp more than X minutes ago, since these are obviously records that were in some way interrupted they can be pruned from the database or flagged to an administrator to investigate.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.