Yii的:使用活动记录与自动提交关闭MySQL服务器 [英] Yii: using active record with autocommit off on mysql server
问题描述
只是写了Yii的应用程序和开发MySQL服务器上自动提交设置为true。现在,当应用程序投入生产我才意识到MySQL服务器自动提交设置为false。该应用程序是用活动记录保存(其中自动提交)。有没有办法,我可以在配置数据库文件设置,而无需添加的BeginTransaction,并承诺在每次写入到数据库的变量?
Just wrote a Yii app and on the development mysql server the autocommit was set to true. Now when the app went into production I just realized that the mysql server autocommit is set to false. The app is using active record to save (which auto commits). Is there a variable that I can set in the config db file instead of having to add a beginTransaction and commit in each write to the db?
推荐答案
CDbConnection拥有的 自动提交
财产。我还没有测试尚未虽然。
CDbConnection has an autoCommit
property. I haven't tested it yet though.
请尝试使用 CDbConnection :: initSQLs
并执行 SET AUTOCOMMIT = 1
每次连接时的时间。
Try using CDbConnection::initSQLs
and execute SET AUTOCOMMIT=1
every time a connection is made.
'db'=>array(
...
'initSQLs'=>array('SET AUTOCOMMIT=1',),
...
);
这篇关于Yii的:使用活动记录与自动提交关闭MySQL服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!