我有个小问题。我有一个Cakephp 3.6项目。所有操作都很好,但是当我想要删除一个控制器中的记录时,会显示我的错误。
已在嵌套事务Cake\Database\Exception\NestedTransactionRollbackException中调用了无法提交事务- rollback()
蛋糕\ORM\表->删除
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)) {上突出显示。
我能做些什么?
发布于 2018-08-08 02:21:36
默认情况下,所有删除都发生在事务中。使用atomic禁用事务如何?
像这样的
$this->News->delete($news, ['atomic' => false]);
https://stackoverflow.com/questions/51722324
复制相似问题