這種方法確實只有保存,但我想它會做插入,更新和CI中刪除如何創建所有CRUD操作將在笨執行方法
//Gallery Category CRUD Module
public function galleryCategory(){
if (!empty($_POST['gallery_cat_name'])){
$data = $this->input->post();
$data['gallery_cat_date'] = date("Y-m-d", strtotime(str_replace('/', '-', $this->input->post('gallery_cat_date'))));
//Data save
$response = $this->MyModel->save('gallery_category', $data);
if ($response) {
$sdata['success_alert'] = "Saved successfully";
}else{
$sdata['failure_alert'] = "Not Saved successfully";
}
$this->session->set_userdata($sdata);
redirect('back/galleryCategoryCreate');
}else{
$sdata['failure_alert'] = "Try again";
$this->session->set_userdata($sdata);
redirect('back/galleryCategoryCreate');
}
}
你聽說過codeIgniter中的$ this-> db嗎? –