title: Codeigniter get all rows from db
body: <p>I'm working on task manager where have 2 types of user: Administrators(all privileges), and Users(limited privileges).</p>
  
  <p>Here's my task function in controller</p>
  
  <pre><code>function task($id) {
      $data = array(
          'query' =&gt; $this-&gt;main_model-&gt;get_task($id),
          'task_id' =&gt; $id,
          );
      $data2['comments'] = $this-&gt;main_model-&gt;get_comments($id);
  
      $this-&gt;load-&gt;library('form_validation');
      $this-&gt;load-&gt;helper('security');
  
      $this-&gt;form_validation-&gt;set_rules('comment_text', 'comment_text', 'trim|required|strip_tags|xss_clean');
  
      if ($this-&gt;form_validation-&gt;run() === FALSE)
      {
          if($this-&gt;main_model-&gt;get_task($id))
          {
              foreach ($this-&gt;main_model-&gt;get_task($id) as $tas)
              {
                  $data = array(
                      'title' =&gt; $tas-&gt;task_name,
                      'desc' =&gt; $tas-&gt;task_description,
                      'date_created' =&gt; $tas-&gt;date,
                      'date_started' =&gt; $tas-&gt;task_start_date,
                      'deadline' =&gt; $tas-&gt;task_deadline,
                      'creator' =&gt; $tas-&gt;task_creator,
                      'owner' =&gt; $tas-&gt;task_owner, 
                      'attach'=&gt;$tas-&gt;attachment_name,
                      'status'=&gt;$tas-&gt;task_status,
                      'priority'=&gt;$tas-&gt;task_priority,
                      'task_id'=&gt;$tas-&gt;ID_task,
                      'base_url' =&gt; base_url()
                      );
              }
              $data1 = array(
                  'emps' =&gt; $this-&gt;main_model-&gt;get_employees(),
                  'creator' =&gt; $this-&gt;main_model-&gt;get_details($id),
                  'owner' =&gt; $this-&gt;main_model-&gt;get_owner($id)
                  );
               if ($this-&gt;session-&gt;userdata('employee_type') == 3) {
  
               $qu = $this-&gt;main_model-&gt;permission();
               $id = $this-&gt;session-&gt;userdata('id');
               $id_emp = $this-&gt;uri-&gt;segment(3);
               //foreach ($qu as $q) {
              if (in_array($id, $qu[0]) &amp;&amp; in_array($id_emp, $qu[0])) {
  
                  $this-&gt;load-&gt;view('task', array_merge($data, $data1, $data2));
  
               }
             else {
                  echo "No Permission to access this task";
                  }
              }
          }
      }
      else
      {
          $config['upload_path'] = './uploads/';
          $config['allowed_types'] = 'doc|docx|pdf|txt|text|rtf|jpg|gif|png'; 
          $config['max_size'] = '1024';
  
          $this-&gt;load-&gt;library('upload', $config);
  
          if (!$this-&gt;upload-&gt;do_upload()) {   
              if ("You did not select a file to upload." != $this-&gt;upload-&gt;display_errors('','')) {  
                  $error = array('error' =&gt; $this-&gt;upload-&gt;display_errors());
                  $this-&gt;load-&gt;view('task', $error);
              }  
              else {  
                  $this-&gt;main_model-&gt;set_comments($id);
                  redirect(current_url());
              }  
          }  
          else {  
              $data = array('upload_data' =&gt; $this-&gt;upload-&gt;data());
              $data1 = $this-&gt;upload-&gt;data();
              $data2 = $data1['file_name'];
              $this-&gt;main_model-&gt;set_comments($id);
              $this-&gt;main_model-&gt;set_attachment($id, $data2);
              redirect(current_url());
          }  
      }
  </code></pre>
  
  <p>}</p>
  
  <p>and my permission function in model:</p>
  
  <pre><code>function permission() {
      $query = $this-&gt;db-&gt;get('employees_tasks');
      $ret = $query-&gt;result_array();
  
  
      return $ret;
  }
  </code></pre>
  
  <p>What I'm trying to do is, get all data from database <code>employee_tasks</code> check if the <code>ID_task</code> and <code>ID_employee</code> are in the same row in database, but I can't get it working, I only getting first row of database, not the others, and that's my <code>key</code> problem, get all rows from db.
  I tried query database with <code>result</code>, <code>result_array</code>, <code>row</code>, <code>row_array</code>, but for some reason everything is listing only first row in db. Any Help would be appreciated.</p>