CakePHP's built-in MySQL datasource provides some basic transaction support by sending all unknown method calls directly to the datasource. However, this only enables us to use some basic transaction commands, and any locking would have to be performed through manual SQL queries.
Note
Table locking is a mechanism to effectively manage concurrent access to table contents by different client sessions. More information about locking in MySQL is available at http://dev.mysql.com/doc/refman/5.5/en/internal-locking.html.
This recipe shows how to modify an existing datasource by implementing better transaction support to the MySQL driver, adding locking operations, and finally allowing a recovery procedure for locked queries.
Note
More information about transaction support in MySQL databases is available at http://dev.mysql.com/doc/refman/5.5/en/commit.html.