php - i am getting null value from a function in model -
i using codeigniter. need select employee detail using employee id , store selected detail in table. have function in controller file given below
public function delete() { //product id $id = $this->uri->segment(4); $data_to_store = $this->employee_model->get_employees_by_id($id); $data = array('id'=> $data_to_store['id'], 'emp_first_name' => $data_to_store['emp_first_name'], 'emp_last_name' => $data_to_store['emp_last_name'], 'emp_email_id' => $data_to_store['emp_email_id'], 'emp_emergency_contact' => $data_to_store['emp_emergency_contact'], 'category' => $data_to_store['category'], 'emp_id_card' => $data_to_store['emp_id_card'], 'emp_time_in' => $data_to_store['emp_time_in'], 'emp_time_out' => $data_to_store['emp_time_out'], 'emp_date_of_hire' => $data_to_store['emp_date_of_hire'], 'emp_date_of_termination' => $data_to_store['emp_date_of_termination'], 'emp_date_of_rehire' => $data_to_store['emp_date_of_rehire'], 'emp_reference_num' => $data_to_store['emp_reference_num'], 'emp_service_limitation' => $data_to_store['emp_service_limitation'], 'chair_renter' => $data_to_store['chair_renter'] ); $this->employee_model->store_deleted_employee($data); redirect('admin/employee'); } in function getting employee id , call function get_employee_by_id($id) in model file. model file
public function get_employees_by_id($id) { $this->db->select('employee.id'); $this->db->select('employee.emp_first_name'); $this->db->select('employee.emp_last_name'); $this->db->select('employee.emp_email_id'); $this->db->select('employee.emp_emergency_contact'); $this->db->select('employee.category'); $this->db->select('employee.emp_id_card'); $this->db->select('employee.emp_time_in'); $this->db->select('employee.emp_time_out'); $this->db->select('employee.emp_date_of_hire'); $this->db->select('employee.emp_date_of_termination'); $this->db->select('employee.emp_date_of_rehire'); $this->db->select('employee.emp_reference_num'); $this->db->select('employee.emp_service_limitation'); $this->db->select('employee.chair_renter'); $this->db->from('employee'); $this->db->where('id', $id); $query = $this->db->get(); return $query->result_array(); } by calling function getting following error.
error number: 1048 column 'emp_id_card' cannot null insert `deleted_employee` (`id`, `emp_first_name`, `emp_last_name`, `emp_email_id`, `emp_emergency_contact`, `category`, `emp_id_card`, `emp_time_in`, `emp_time_out`, `emp_date_of_hire`, `emp_date_of_termination`, `emp_date_of_rehire`, `emp_reference_num`, `emp_service_limitation`, `chair_renter`) values (null, null, null, null, null, null, null, null, null, null, null, null, null, null, null) filename: c:\xampp\htdocs\elfanto\elfanto_billing\system\database\db_driver.php line number: 330 can me code.
edit 01
public function delete_confirm() { $id = $this->uri->segment(4); $this->employee_model->delete_employee($id); redirect('admin/employee'); } i need call function when function action overs..
result_array(); method returns query result pure array, or empty array when no result produced. typically you’ll use in foreach loop:
intesd of return
return $query->row_array(); it returns array per controller code
Comments
Post a Comment