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 3 of 3

Thread: Data Integrity

  1. #1
    New Coder
    Join Date
    Jul 2006
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Data Integrity

    I looked for this sort of subject in the PHP forum but i only found related subjects in the ASP forum.

    I have 2 tables in my DB. The two are related. They have a 1 to Many Relationship. When i am adding new data to those tables i first do a INSERT in the first table then i do the INSERT in the second table.

    What if something goes wrong between the first and second inserts? I don't want my data to be written to the first table if my the other data isn't written on the second table?

    What are your guys opinion on this? How do i use like rollback, commit in PHP?

    Thanks a million

  • #2
    New Coder
    Join Date
    Jul 2005
    Posts
    81
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi, very good question there are some answers which i know as you know maybe InnoDB support constrains, that's mean you could prevent any problems if you create you tables in a such way. Another solution is to use lock tables read more in mysql manual about it. Good luck
    If you can not find a decision, maybe you have to try to change a problem

    http://www.gunman.co.nr
    http://bglinux.org

  • #3
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    the programming language is irrelevant, what database are you using?

    If it's MySQL, then I believe you'll need to be using InnoDB tables for transactions to work.

    Have a look at: http://dev.mysql.com/books/mysqlpres...rial/ch10.html
    My thoughts on some things: http://codemeetsmusic.com
    And my scrapbook of cool things: http://gjones.tumblr.com


  •  

    Posting Permissions

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