Cakephp - 无法提交事务 - 回滚()
Cakephp - Cannot commit transaction - rollback()
我有个小问题。我有一个 Cakephp 3.6 项目。一切正常,但是当我想删除一个控制器中的记录时显示错误。
无法提交事务 - rollback() 已在嵌套事务中调用
Cake\Database\Exception\NestedTransactionRollbackException
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]);
我有个小问题。我有一个 Cakephp 3.6 项目。一切正常,但是当我想删除一个控制器中的记录时显示错误。
无法提交事务 - rollback() 已在嵌套事务中调用 Cake\Database\Exception\NestedTransactionRollbackException
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]);