与orm的kohana交易 [英] kohana transaction with orm

查看:91
本文介绍了与orm的kohana交易的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能(如何)使用kohana ORM使用mysql事务和回滚?

is it possible (how) to use mysql transactions and rollbacks using kohana ORM ?

推荐答案

Kohana 3.x中的SQL事务处理方式与2.x中不同.在3.x中,数据库类带有事务方法:

SQL Transactions in Kohana 3.x are not done the same way as in 2.x. In 3.x, the database class comes with transaction methods:

$db->begin();
$db->commit();
$db->rollback();

如果您使用的是ORM内容,这也可以使用.只需在ORM保存,更新,删除a或删除之前启动事务即可.

This also works if you are using ORM stuff. Just initiate the transaction before ORM saves, updates, a or deletes.

在这篇文章中阅读更多内容: http://dev.strategystar.net/2011/10/sql-transactions-with-kohana-3-x/

Read more in this post: http://dev.strategystar.net/2011/10/sql-transactions-with-kohana-3-x/

在2.x版本中,交易必须手动完成:

In 2.x, transactions had to be done manually:

$this->db->query("START TRANSACTION")

这篇关于与orm的kohana交易的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆