QUERY 1:
$link = mysql_connect('localhost', 'root', '');
mysql_select_db('rems', $link);
mysql_query('SET AUTOCOMMIT=0; START TRANSACTION', $link);
mysql_query('DELETE FROM admins WHERE admin_id=4', $link);
mysql_query('ROLLBACK; SET AUTOCOMMIT=1', $link);
QUERY 2:
$link = mysql_connect('localhost', 'root', '');
mysql_select_db('rems', $link);
mysql_query('SET AUTOCOMMIT=0;START TRANSACTION;
DELETE FROM admins WHERE admin_id=4;
ROLLBACK; SET AUTOCOMMIT=1', $link);
From the above two queries the first one does not execute properly (transaction does not work) because of executing the queries separately by calling the mysql_query functions multiple times. But i need it do be done by this way. That is i need the result by the first way (calling mysql_query function several times for a single transaction)
Any IDEA please???
ROLLBACKandSET AUTOCOMMIT=1in the last statement seem similarly ill-advised. When you say it doesn't work, what exactly is happening? Are you getting an error? Or is nothing happening? Note that since you are rolling back the transaction, you expect nothing to happen.DELETEstatement). Hence no actual delete, but that has nothing to do with a ROLLBACK, but a general error (try it: COMMIT there won't work)