[英]Cakephp - Cannot commit transaction - rollback()
我有一点问题。 我有一个Cakephp 3.6项目。 一切正常,但是当我想删除一个控制器中的记录时,显示错误。
无法提交事务-嵌套事务 Cake \\ Database \\ Exception \\ NestedTransactionRollbackException中已经调用了rollback()
Cake \\ ORM \\ Table->删除
APP / Controller \\ NewsController.php,第131行
这是我在NewsController.php中的删除操作
public function delete($id = null)
{
$this->request->allowMethod(['post', 'delete']);
$news = $this->News->get($id);
if ($this->News->delete($news)) {
$this->Flash->success(__('The news has been deleted.'));
} else {
$this->Flash->error(__('The news could not be deleted. Please, try again.'));
}
return $this->redirect(['action' => 'index']);
}
错误会突出显示在if($ this-> News-> delete($ news)){
我能做什么 ?
默认情况下,所有删除都在事务中发生。 禁用atomic
交易怎么样?
喜欢的东西
$this->News->delete($news, ['atomic' => false]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.