cakephp 事务

mysql 引擎有以下几种 :

http://blog.csdn.net/zdwzzu2006/article/details/3207854


Transactions

To perform a transaction, a model’s tables must be of a type thatsupports transactions.

All transaction methods must be performed on a model’s DataSourceobject. To get a model’s DataSource from within the model, use:

$dataSource = $this->getDataSource();

You can then use the data source to start, commit, or roll backtransactions.

$dataSource->begin($this);

//Perform some tasks

if(/*all's well*/) {
    $dataSource->commit($this);
} else {
    $dataSource->rollback($this);
}

事物要使用model 的DataSourceobject,然后就可以在model方法中使用事务。






posted @ 2012-12-11 15:34  lein.wang  Views(127)  Comments(0Edit  收藏  举报