我得到了这些多态关系:
staff:
id - integer
name - string
orders:
id - integer
price - integer
photos:
id - integer
path - string
imageable_id - integer
imageable_type - string在控制器中:
public function example() {
\DB::beginTransaction();
try {
$staff = Staff::findOrFail(1);
$row = $staff->photos()->create([ 'path' => 1 ]);
$row->path = 2;
$row->save();
abort(445);
} catch( \Exception $e ) {
\DB::rollback()
}
}不出所料,当前行必须从photos表中删除,但它仍然存在,路径=2
我是不是马上就会想到?或者这是一场误会?
发布于 2016-07-25 18:04:29
如果没有回滚事务,那么由于MyISAM表不支持回滚,所以有一种可能是您的表使用了MyISAM作为引擎。
因此,请仔细检查表的引擎是否正确设置为InnoDB。
https://stackoverflow.com/questions/38562296
复制相似问题