asmith Posted December 5, 2007 Share Posted December 5, 2007 for registering user, i want to insert 2 rows in 2 diffrent tables for each user, i have put in the code that if the row 1 couldn't insert into table 1 , so don't insert row 2 in the table 2. and if row 1 inserted, but row 2 couln't, then delete row 1 . how much precent it is the posibilty that inserting to mysql tables fails ? in other words , do i really have to do such coding ? Quote Link to comment https://forums.phpfreaks.com/topic/80231-should-i-do-that/ Share on other sites More sharing options...
fenway Posted December 5, 2007 Share Posted December 5, 2007 This is what's known as a "transaction" -- MyISAM tables don't support this, but InnoDB (and others) do. If anthing "inside" fails, you simply rollback, and then it's like it's never happened (though you still need to handle user notification). Inserting won't "fail" unless there's a DB error (e.g. server crashes), you're statement isn't valid (shouldn't ever happen on a production server), etc.... Quote Link to comment https://forums.phpfreaks.com/topic/80231-should-i-do-that/#findComment-406916 Share on other sites More sharing options...
asmith Posted December 6, 2007 Author Share Posted December 6, 2007 so it is a thing that happens 1 in a million ? Quote Link to comment https://forums.phpfreaks.com/topic/80231-should-i-do-that/#findComment-407874 Share on other sites More sharing options...
fenway Posted December 6, 2007 Share Posted December 6, 2007 It's as reliable as any other reliable multi-threaded server application -- if you can't afford any failure, that's a different story. Quote Link to comment https://forums.phpfreaks.com/topic/80231-should-i-do-that/#findComment-407972 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.