Answers for "codeigniter delete"

PHP
0

codeigniter delete record by id

//include this in your controller
public function delete_record($eid){
    $delete = $this->your_model->delete_record($id);
    if ($delete == FALSE) {
      $this->session->set_flashdata('error', 'Employee deletion failed, try again.');
      redirect('your_view', 'refresh');
    } else {
      $this->session->set_flashdata('success', 'Employee deleted successfully.');
      redirect('your_view', 'refresh');
    }

}

//include this in your model
public function delete_record($id){
	$deleted = $this->db->delete('mytable', array('id' => $id));
    return $deleted;
}
Posted by: Guest on February-25-2021
2

codeigniter where order by

$this->db->select('ae_users.employee_id, ae_users.emp_name, ae_users.emp_name2, ae_users.emp_name3');
		$this->db->from('ae_users');                
		$this->db->where_in('ae_users.employee_id',$employee_ids);
                $this->db->_protect_identifiers = FALSE; // stop CI adding backticks
                $order = sprintf('FIELD(ae_users.employee_id, %s)', implode(', ', $employee_ids));
                $this->db->order_by($order);
                $this->db->_protect_identifiers = TRUE; 
		$query =$this->db->get();
               // echo '<pre>'; print_r($this->db->last_query());exit;
		if ($query->num_rows()) {
			return $query->result_array();
		} else {
			return 0;
		}
Posted by: Guest on September-16-2020

Code answers related to "codeigniter delete"

Browse Popular Code Answers by Language