title: Get username from userid in a view
body: <p>I am getting data from a table and showing in my view (codeigniter). In the view I have user id which is of course an integer. I need to get username from user id. How i will get the username from id ? </p>
  
  <p>Model code is below .</p>
  
  <pre><code>class Resumemodel extends CI_Model
  {
     function getallresume()
    {
       $query = $this-&gt;db-&gt;get('resume');
          return $query;
    }
  }
  </code></pre>
  
  <p>Controller code is below.</p>
  
  <pre><code>class Resumec extends CI_Controller 
  {
    function resumelist()
    {
      $this-&gt;load-&gt;model('Resumemodel');
      $query = $this-&gt;Resumemodel-&gt;getallresume();
      $dt['main_content'] = 'admin/resumeinfo';   
      $dt['query'] = $query;
      $this-&gt;load-&gt;view('admin/includes/template.php',$dt);
    }
   }
  </code></pre>
  
  <p>view is below (only required part i put here)</p>
  
  <pre><code>foreach ($query-&gt;result() as $row)
  {
     $id = $row-&gt;user_id;
     // other table data.
   }
  </code></pre>
  
  <p>So from user id how i will get user name without join Query ?</p>
  
  <p>PS <strong>Please provide answer without join query. It will work with join query, but I am looking for alternatives.</strong></p>
  
  <p>I tried with this- </p>
  
  <pre><code> $objResume = new resumec();  //resumec is the controller
   $username = $objResume-&gt;get_username($id); // get_username is function to get username.
   echo $username;
  </code></pre>
  
  <p>This is working but this is not proper / good way according to MVC logic. So is there any alternatives ?</p>
  
  <p>edit - 2 tables are there. 'user' and 'resume'. user_id is in 'resume' table and uid, username is in 'user' table.</p>