Forums / Developer / MySQL Use / Comment60508

Author Topic

Bertrand Dunogier

Friday 30 July 2010 12:20:01 am

Comment60508

No problem whatsoever with your english, Laurent. Most of us here don't speak english as their native language anyway :)

Regarding the set autocommit part, it is a bit unrelated: we indeed don't disable autocommit, because, well, there is no need to. When a query isn't considered transaction unsafe (e.g. it can be executed independantly from the previous one), we just execute the query. Now if a set of queries are interdependant on each other, we do explicitely start a transaction ($db->begin()), and as the manual says (http://dev.mysql.com/doc/refman/5.0/en/commit.html), starting a transaction will disable autocommit.

We then just execute the "transaction unsafe" queries, and commit them using $db->commit(). If an error occurs in the transaction, the query is automatically rollbacked by the DB layer. Does it make sense ?

Bertrand Dunogier
eZ Systems Engineering, Lyon
http://twitter.com/bdunogier
http://gplus.to/BertrandDunogier