hoopz Posted August 12, 2008 Share Posted August 12, 2008 Hey everyone! Thanks in advance for your help! I am writing a function that Inserts data into 2 tables within a database. The Pseudo code is as follows: - insert into user_table ...... - get last id - insert into shipping_info ...... I'm a self taught in PHP/MySQL so I don't know all the proper coding practices. My question is this: if either of those inserts fail, especially the 2nd one, I need to remove any data that has been inserted and then generate an error message for the user. Here's what I'm thinking, please let me know if there is a better way to do this: - insert into user_table ..... - if success then continue else generate error message and return - get last id - insert into shipping_info ..... - if success then continue else remove data from previous insert, generate error message, and return Is this typically how it's done? Thanks again, - H Quote Link to comment Share on other sites More sharing options...
fenway Posted August 13, 2008 Share Posted August 13, 2008 How about transcatiosn? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.