问题
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