如何在cakephp中使用mysql事务(不使用saveAll()方法)?我正在使用cakephp版本1.2我搜索了很多但没有得到任何好的例子如果有人知道请帮助我提前感谢...
答案 0 :(得分:0)
这是一篇博客文章,其中包含示例:http://monmonja.com/blog/2008/07/transaction-on-cakephp-12/
我建议您升级到1.3。 CakePHP 2.0即将推出。 1.3的手册输入位于:http://book.cakephp.org/view/1633/Transactions
<强>更新强>
CakePHP 2.0也很相似 - http://book.cakephp.org/2.0/en/models/transactions.html
$dataSource = $this->getDataSource();
$dataSource->begin();
// Perform some tasks
if (/*all's well*/) {
$dataSource->commit();
} else {
$dataSource->rollback();
}