我試圖軟刪除一條記錄,但是當我更新記錄時,我也得到了6條新的空記錄。這裏是我的編輯代碼CakePHP:編輯記錄還增加了新記錄
public function del($id = null){
$dt = $this->Store->findById($id);
$dt["Store"]["status"] = 0;
if($this->Store->save($dt)){
$this->Session->setFlash("Your Store has been Deleted");
$this->redirect("/stores/");
}
}
我也試過 $ this-> Store-> id = $ id; $ this-> Store-> saveField('status',0); 但結果沒有任何區別 – user612703 2013-05-03 23:23:39
@nathan,我正在嘗試不同的技巧,我可以在互聯網上找到它的工作,所以它是其中之一,當我在這裏複製代碼時,它就在那裏。 使用這個結果沒有什麼區別。我現在要從這裏刪除它 – user612703 2013-05-03 23:26:18
您可以添加Store模型的代碼和數據庫表的定義嗎? – thaJeztah 2013-05-06 21:16:54