I wrote the following 'insert code' in a way that I can use it many times. So without writing the table name in the model I could write the table name in the controller.
model function
function insertTable($table, $data) {
$this->db->insert($table, $data);
return $this->db->insert_id();
}
controller instruction
$insert = $this->Model_Action->insertTable('student',$student_data)
But I want to do the same in the following code as well. Is there a way to replace the p_id as $id?
Model
function delete_by_id($id)
{
$this->db->where('p_id', $id);
$this->db->delete('parent');
}
Controller
public function student_delete($id)
{
$this->load->model('Model_Action');
$this->Model_Action->delete_by_id($id);
echo json_encode(array("status" => TRUE));
}