0
I have two table, categories hasMany products id name active products belongsTo categories id name category_id active
나는 또한 내가/업데이트 관련 제품을 수정할 수 있도록 범주에 관련된 상품을 표시하고 같은 시간에, 카테고리를 편집하고 카테고리.문제/수정
문제 : - 잘 작동하는 카테고리에 대해 더 많은 제품을 추가했지만 카테고리에서 일부 제품을 제거하면 제거 된 제품이 데이터베이스에서 삭제되지 않습니다. 그래서이 기능이 CakePHP에 의해 지원되는지 아닌지 알고 싶습니다. 그렇다면 내가 잘못 가고있는 곳을 찾도록 도와주세요.
여기에 저장 코드 : -이
당신이 당신의 hasMany의 관계를 설정$categoryProducts = $this->Categories->get(1, [
'contain' => 'Products'
]);
if($this->request->is['post', 'put']){
$entity = $this->Categories->patchEntity($categoryProducts, $this->request->data);
$this->Categories->save($entity);
}