I want to delete a record in CodeIgniter but it's getting an error.
This is the model I created:
public function delete_by_id($id) {
$My_Multiple_Statements_Array = array('id' => $id, 'tipe' => $tipe);
$this->db->where($My_Multiple_Statements_Array);
$this->db->delete($this->table);
}
Controller:
public function ajax_delete($id) {
$this->paket->delete_by_id($id);
echo json_encode(array("status" => TRUE));
}
And AJAX:
function delete_person(id)
{
if (confirm('Are you sure delete this data?'))
{
// ajax delete data to database
$.ajax({
url: "<?php echo site_url('paket/ajax_delete') ?>/" + id ,
type: "POST",
dataType: "JSON",
success: function (data)
{
//if success reload ajax table
$('#modal_form').modal('hide');
reload_table();
},
error: function (jqXHR, textStatus, errorThrown)
{
alert('Error deleting data');
}
});
}
}
Why can't it delete the record?
$tipein model