Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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