Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Apr 2005
    Location
    Lahore, Pakistan
    Posts
    150
    Thanks
    2
    Thanked 0 Times in 0 Posts

    A Strange problem- Need solution

    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

    plz reply

    eshban

  • #2
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,797
    Thanks
    19
    Thanked 156 Times in 147 Posts
    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?

    No, seriously, I can't understand what the problem is....could you be more clear?

    Include some code....
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  • #3
    Regular Coder
    Join Date
    Apr 2005
    Location
    Lahore, Pakistan
    Posts
    150
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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.

    plz reply

  • #4
    Regular Coder
    Join Date
    Feb 2005
    Location
    West Midlands, UK
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Last edited by delinear; 07-09-2005 at 12:04 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •