Yii: using active record with autocommit off on mysql server

自作多情 提交于 2019-12-24 12:54:50

问题


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?


回答1:


CDbConnection has an autoCommit property. I haven't tested it yet though.

EDIT because of PHP MySQL Yii - database reading not writing

Try using CDbConnection::initSQLs and execute SET AUTOCOMMIT=1 every time a connection is made.

'db'=>array(
    ...
    'initSQLs'=>array('SET AUTOCOMMIT=1',),
    ...
);


来源:https://stackoverflow.com/questions/14330815/yii-using-active-record-with-autocommit-off-on-mysql-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!