title: codeigniter ion auth getting user id
body: <p>I need to get the user id of the person logged in, so that i can run a query for that user. Im using ion auth, should i use a session or call it from the db, should i use a helper or not? anyway, heres what im trying to do:</p>
  
  <p>example: how many work orders does logged in user have?
  query would be: select * from work_orders WHERE status = "1" AND userid = "%THE LOGGED IN USER"</p>
  
  <p>here is my controller, which doesnt have the "get user id" code:</p>
  
  <pre><code>public function index()
  {
      $this-&gt;load-&gt;view('templates/header');
      $data['total_open_wo'] = $this-&gt;Home_model-&gt;total_open_wo();
      $data['result'] = $this-&gt;Home_model-&gt;index();
      $this-&gt;load-&gt;view('home', $data);
      $this-&gt;load-&gt;view('templates/footer');
  
  }
  </code></pre>
  
  <p>here is my model:</p>
  
  <pre><code>public function total_open_wo()  {
  
          $this-&gt;db-&gt;where('status', "1");
          $this-&gt;db-&gt;where('tid', "NEED_THE_USER_ID");
          $num = $this-&gt;db-&gt;count_all_results('work_orders');
  
          return ($num);
      }
  </code></pre>