Reputation: 25
i have a problem in my delete function. the status showing the image and data was successfully deleted from directory and database, but when i check in the database, no data and image was deleted from directory and database. here is my delete link in view
<a class="btn btn-orange btn-xs" href="<?=base_url()?>index.php/root/slider/hapus/?id=<?=$row->id?>"><i class="fa fa-trash-o"></i></a>
here is my delete function in controller
public function hapus(){
$id = $this->input->post('id');
$path = './asset/slider/uploads/';
$path1 = './asset/slider/hasil_resize/';
$arraydelete = array('id'=>$id);
$rowdel = $this->Model_slider->get_byimage($arraydelete);
@unlink($path.$path1.$rowdel->namafile);
$this->Model_slider->get_delete($arraydelete);
$this->session->set_flashdata("pesan", "<div class=\"col-md-12\"><div class=\"alert alert-danger\" id=\"alert\">Berhasil hapus data Gambar dan file gambar dari folder !!</div></div>");
redirect('root/slider');
}
and here is my Model
var $tabel = 'slider_home';
function __construct() {
parent::__construct();
}
function get_allimage() {
$this->db->from($this->tabel);
$query = $this->db->get();
return $query->result();
}
function get_byimage($where) {
$this->db->from($this->tabel);
$this->db->where($where);
$query = $this->db->get();
if ($query->num_rows() == 1) {
return $query->row();
}
}
function get_delete($where){
$this->db->where($where);
$this->db->delete($this->tabel);
return TRUE;
}
i need solution for this problem, every time i checked it and fix it, the result still same. Please help me
Upvotes: 1
Views: 442
Reputation: 64
Did you debug your app? Does you have id of image in your $id variable? You check POST, but send id of image in url, for this you need GET
Upvotes: 1