radiations3 Posted June 6, 2012 Share Posted June 6, 2012 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!!!"; } Quote Link to comment https://forums.phpfreaks.com/topic/263754-basic-question-regarding-php-mysql-and-transaction/ Share on other sites More sharing options...
smoseley Posted June 6, 2012 Share Posted June 6, 2012 Yeah, that'll work. Quote Link to comment https://forums.phpfreaks.com/topic/263754-basic-question-regarding-php-mysql-and-transaction/#findComment-1351609 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.