title: CodeIgniter Undefined Property Error
body: <p>I have a table in my app named admin and I'm using the code below to select a record based off of submitted email and password. I'm getting "undefined property stdclass" errors for first_name, last_name and admin_role. I've triple checked and those are the names of the columns in my table. What am I doing wrong? I am autoloading the database and session libraries. Is it okay to set session data in a model?</p>
  
  <p>Model Code:</p>
  
  <pre><code>public function can_sign_in() {
      $this-&gt;db-&gt;select('admin_id', 'first_name', 'last_name', 'admin_role');
      $this-&gt;db-&gt;where('admin_email', $this-&gt;input-&gt;post('admin_email'));
      $this-&gt;db-&gt;where('admin_password', md5($this-&gt;input-&gt;post('admin_password')));
      $query = $this-&gt;db-&gt;get('admin');
  
      if($query-&gt;num_rows() == 1) {
          foreach ($query-&gt;result() as $row) {
              $admin[] = array(
                  'admin_id' =&gt; $row-&gt;admin_id,
                  'first_name' =&gt; $row-&gt;first_name,
                  'last_name' =&gt; $row-&gt;last_name,
                  'admin_role' =&gt; $row-&gt;admin_role
              );
            $this-&gt;session-&gt;set_userdata($admin);
         }
          return true;
      } else {
          return false;
      }
  }
  </code></pre>