View Full Version : Data Integrity

01-25-2007, 08:02 AM
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

01-25-2007, 08:44 AM
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

01-25-2007, 09:21 AM
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/mysqlpress/mysql-tutorial/ch10.html