I am new to PHP. All my codes of accessing MySQL in hand are from google. I got a queation about transaction. Following a sample from google, I have
$conn = mysql_pconnect(...);
query('set autocommit=0;');
query('start transaction;');
foo1(); // some sqls updating table1
foo2(); // some sqls updating table2
foo3(); // some sqls updating table3
if (ok)
query('commit;');
else query('rollback');
here, query() is an user-defined function for querying the database with the given sql.
Before the stage of foo3, foo1 and foo2 has already change the table, and in foo3 a piece of code is added for confirmation. The code given above seems ok to me. However, I try to push the 'BACK' button on IE rather than pushing the 'confirmation' in foo3 and it makes mysql down ( I cannot access table1, table2 unless I restart mysqld). I try to repeat the experiment but nothing wrong again. It's confusing me! I WONDER if it will crack the mysql if I start a transaction without correctly closing it by tirggering 'commit' or 'rollback'.