I need to get a user ID to log in so that I can execute a request for this user. I use ion auth, should I use a session or call it from db, should I use a helper or not? Anyway, this is what I am trying to do:
example: how many work orders are registered with a user? query: select * from work_orders WHERE status = "1" AND userid = "% THE LOGGED IN USER"
here is my controller that does not have a "get user id" code:
public function index() { $this->load->view('templates/header'); $data['total_open_wo'] = $this->Home_model->total_open_wo(); $data['result'] = $this->Home_model->index(); $this->load->view('home', $data); $this->load->view('templates/footer'); }
here is my model:
public function total_open_wo() { $this->db->where('status', "1"); $this->db->where('tid', "NEED_THE_USER_ID"); $num = $this->db->count_all_results('work_orders'); return ($num); }
source share