2
3 개의 기사 이름, 설명, 주소가 있습니다.cakephp 3.x 캐스케이드 삭제가 작동하지 않습니다.
articles -> fields(id,title,body)
comments -> fields(id,article_id,comment)
addresses-> fields(id,article_id,address)
내 기사 컨트롤러에서 나는 dependent => true 및 cascadeCallbacks => true를 유지했습니다. 먼저 종속성 => true로 시도했는데 작업이 중단 된 후 캐스케이드가 추가되었지만 여전히 작동하지 않습니다. 아래는 제 코드입니다.
$this->hasMany('Comments', [
'className' => 'Comments',
'dependent' => true,
'cascadeCallbacks' => true,
]);
$this->hasOne('Addresses',[
'dependent' => true,
'cascadeCallbacks' => true,
]);
그러나 기사를 삭제하는 동안 연결된 레코드는 삭제되지 않습니다.
public function delete($id = null)
{
$this->request->allowMethod(['post', 'delete']);
$article = $this->Articles->get($id);
if ($this->Articles->delete($article)) {
$this->Flash->success(__('The article has been deleted.'));
} else {
$this->Flash->error(__('The article could not be deleted. Please, try again.'));
}
return $this->redirect(['action' => 'index']);
}
내가 실수 한 점을 알려주십시오. 또는 코드를 추가하거나 변경해야합니까? 경기 수 도움
정확한 케이크 버전은 무엇입니까? – arilia
내 cakephp 버전 - 3.3.2 – Pavithra
파일과 네임 스페이스의 이름이 정확합니까? CommentsTable, AddressesTable 등을 말합니다 .. – arilia