【发布时间】:2018-08-07 08:34:06
【问题描述】:
我有一个小问题。我有一个 Cakephp 3.6 项目。一切正常,但是当我想删除一个控制器中的记录时,会显示我的错误。
无法提交事务 - rollback() 已在嵌套事务中调用 Cake\Database\Exception\NestedTransactionRollbackException
Cake\ORM\Table->删除
APP/Controller\NewsController.php,第 131 行
这是我在 NewsController.php 中的 delete 操作
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)) {
上突出显示我能做什么?
【问题讨论】:
标签: php database cakephp transactions cakephp-3.x