l3n*_*nox 1 php database cakephp transactions cakephp-3.x
我有一个小问题。我有一个 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']);
}
Run Code Online (Sandbox Code Playgroud)
并且错误突出显示在if ($this->News->delete($news)) {
我能做什么 ?
默认情况下,所有删除都发生在事务中。您如何禁用与 的交易atomic?
喜欢的东西
$this->News->delete($news, ['atomic' => false]);
| 归档时间: |
|
| 查看次数: |
1685 次 |
| 最近记录: |