title: Trying to get property of non-object error using codeigniter
body: <p>I've problem with codeigniter. this is the message </p>
  
  <blockquote>
    <p>A PHP Error was encountered</p>
    
    <p>Severity: Notice</p>
    
    <p>Message: Trying to get property of non-object</p>
    
    <p>Filename: employee/detail.php</p>
    
    <p>Line Number: 15</p>
  </blockquote>
  
  <p>I heve model like this:</p>
  
  <pre><code>public function getByID($id){
      $this-&gt;db-&gt;select('*');
      $this-&gt;db-&gt;from('master_employee me'); 
      $this-&gt;db-&gt;join('master_position mp', 'mp.mp_id=me.mp_id');
      $this-&gt;db-&gt;where('me.me_id', $id);
      $query = $this-&gt;db-&gt;get();
      return $query-&gt;row();
  }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>public function edit($id){
      /**
       * [$data get data from database]
       * @var array
       */
      $data = array($id);
      $data['msg']            = $this-&gt;_get_flashdata();
      $data['rows']           = $this-&gt;m_employee-&gt;getByID($id);
      $data['position']       = $this-&gt;m_position-&gt;get();
  
      /**
       * [$html call all wireframe]
       * @var array
       */
      $html = array();
      $html['header']     = $this-&gt;load-&gt;view('admin/header',$data,true);
      $html['kiri']       = $this-&gt;load-&gt;view('admin/kiri',null,true);
      $html['content']    = $this-&gt;load-&gt;view('admin/employee/edit',$data,true);
      $this-&gt;load-&gt;view('admin/template',$html);
  }
  </code></pre>
  
  <p>and view like this</p>
  
  <pre><code>&lt;?php if($rows-&gt;me_photo == NULL): ?&gt;
  &lt;img src="&lt;?php echo base_url('/upload/be/employee/default-no-image.png'); ?&gt;" class="img-responsive" title="no-photo" style="margin-bottom:10px" /&gt;
  &lt;?php else: ?&gt;
  &lt;img src="&lt;?php echo base_url('/upload/be/employee'.$rows-&gt;me_name); ?&gt;" class="img-responsive" style="margin-bottom:10px" /&gt;
  &lt;?php endif; ?&gt;
  </code></pre>
  
  <p>How to solve my problem? Please </p>