开发者

How can i use mysql transaction in cakephp?

开发者 https://www.devze.com 2023-03-01 07:10 出处:网络
How can i use mysql transaction in cakephp (Without using saveAll() method)? i am using cakephp version 1.2 i have searched a lot but did not get any good exam开发者_C百科ple If anyone knows please he

How can i use mysql transaction in cakephp (Without using saveAll() method)? i am using cakephp version 1.2 i have searched a lot but did not get any good exam开发者_C百科ple If anyone knows please help me thanks in advance ...


Here's a blog post with examples : http://monmonja.com/blog/2008/07/transaction-on-cakephp-12/

I recommend you upgrade to 1.3 though. CakePHP 2.0 will be coming out soon. The manual entry for 1.3 is here : http://book.cakephp.org/view/1633/Transactions

UPDATE

CakePHP 2.0 is also similar - 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();
}
0

精彩评论

暂无评论...
验证码 换一张
取 消