25.03.2014, 16:59
Quote:
How would I go about handling transactions? I have one instance where I need, or rather want to perform inserts in a loop. Do I simply execute Start->queries->Commit?
|
Код:
mysql_tquery(SQL, "START TRANSACTION"); for(new i=0; i < 100; ++i) mysql_tquery(SQL, "INSERT INTO foobar (foo) VALUES ('bar')"); mysql_tquery(SQL, "COMMIT");
Quote:
I think you can only do this with unthreaded queries because otherwise you can't make sure in which order the queries get executed.
[...] But unless you don't need a feature like ROLLBACK or something you should stay with common threaded queries. |
Transactions are also good for speed optimizations, because they skip some internal query operations within the MySQL server (table locking and re-indexing I think).