Jump to content

Basic question regarding PHP MYSQL AND TRANSACTION


radiations3

Recommended Posts

Hello, I want to know one thing lets say there is one variable $var1 and insert query is being assign to it then will mysql_query($query1) or die(mysql_error()); this code will make insertion successfully.

 

moreover in the following transaction code will all the queries being inserted on $result = mysql_query('COMMIT');

 

and will the following code make sure that all the insertion successfully inserted into multiple tables because I have been trying to make such functionality that will make sure that on click all the values are being stored in the multiple tables of the database successfully and will not make insertion if insertion is being failed of one table or another.

 

if (mysql_query('BEGIN')) {
    if (
	mysql_query($query1) &&
        mysql_query($query2)  &&
	mysql_query($query3) &&
	mysql_query($insertSQL) 
	)
        $result = mysql_query('COMMIT'); // All queries looked OK, save
    else
{
        mysql_query('ROLLBACK') ; // problems with queries, no changes
	echo "There are some problemo!!!";
	}

Link to comment
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.