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!!!";
	}

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.