[英]Cakephp - Cannot commit transaction - rollback()
I have a little problem. 我有一点问题。 I have a Cakephp 3.6 project.
我有一个Cakephp 3.6项目。 All work fine, but when I want to delete a record in one controller show my a error.
一切正常,但是当我想删除一个控制器中的记录时,显示错误。
Cannot commit transaction - rollback() has been already called in the nested transaction Cake\\Database\\Exception\\NestedTransactionRollbackException 无法提交事务-嵌套事务 Cake \\ Database \\ Exception \\ NestedTransactionRollbackException中已经调用了rollback()
Cake\\ORM\\Table->delete Cake \\ ORM \\ Table->删除
APP/Controller\\NewsController.php, line 131 APP / Controller \\ NewsController.php,第131行
This is my delete action in NewsController.php 这是我在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']);
}
And the error is highlighted on if ($this->News->delete($news)) { 错误会突出显示在if($ this-> News-> delete($ news)){
What can I do ? 我能做什么 ?
By default all deletes happen within a transaction. 默认情况下,所有删除都在事务中发生。 How about you disable the transaction with the
atomic
? 禁用
atomic
交易怎么样?
Something likes 喜欢的东西
$this->News->delete($news, ['atomic' => false]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.