在save()执行之后rollback为什么没有回滚?

WBOY
Release: 2016-06-06 20:22:55
Original
1623 people have browsed it

<code>DB::beginTransaction();
$model = new UserWechat();
$model->unionid = 'od13WwfNk64BQ9ME95S-bzuU7j8A';
$model->save();
DB::rollback();</code>
Copy after login
Copy after login

代码如上,没有按照预期回滚,数据插入了数据库中.
执行原生sql如下, 和预期一致!:

<code>start transaction;
insert into user_wechat (unionid) values('od13WwfNk64BQ9ME95S-bzuU7j8A');
rollback;</code>
Copy after login
Copy after login

难道我错了一万年...

回复内容:

<code>DB::beginTransaction();
$model = new UserWechat();
$model->unionid = 'od13WwfNk64BQ9ME95S-bzuU7j8A';
$model->save();
DB::rollback();</code>
Copy after login
Copy after login

代码如上,没有按照预期回滚,数据插入了数据库中.
执行原生sql如下, 和预期一致!:

<code>start transaction;
insert into user_wechat (unionid) values('od13WwfNk64BQ9ME95S-bzuU7j8A');
rollback;</code>
Copy after login
Copy after login

难道我错了一万年...

你的数据库引擎是InnoDB么?只有InnoDB才支持事务,MyISAM是不支持的哦!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!