Jump to content

should i do that ?


asmith

Recommended Posts

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 ?

 

Link to comment
https://forums.phpfreaks.com/topic/80231-should-i-do-that/
Share on other sites

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....

Link to comment
https://forums.phpfreaks.com/topic/80231-should-i-do-that/#findComment-406916
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.