title: Undefined property: CI_DB_mysql_result::$result
body: <p>I am new to the codeigniter programming. When I am trying to connect with the database and retrieve data from the table, I Found Error like:</p>
  
  <pre><code>A PHP Error was encountered
  Severity: Notice
  Message: Undefined property: CI_DB_mysql_result::$result
  Filename: models/haii.php
  Line Number: 15.
  
  A PHP Error was encountered
  Severity: Warning
  Message: Invalid argument supplied for foreach()
  Filename: views/getquery.php
  Line Number: 2
  </code></pre>
  
  <p>I am using this code to connect with the database using codeigniter:</p>
  
  <h1>Controller:</h1>
  
  <pre><code>&lt;?php
  class product extends CI_Controller
  {
      function __construct()
      {
      }
      function getall()
      {
          $this-&gt;load-&gt;model('haii');
          $data['query']=$this-&gt;haii-&gt;you();
          $this-&gt;load-&gt;view('getquery',$data);
      }
  }
  ?&gt;      
  </code></pre>
  
  <h1>Model:</h1>
  
  <pre><code>&lt;?php
  class haii extends CI_Model
  {
      function __construct()
      {
          parent::__construct();
          $this-&gt;load-&gt;database();
      }
      function you()
      {
          $query=$this-&gt;db-&gt;get('member');
          return $query-&gt;result;
      }
  }
  ?&gt;
  </code></pre>
  
  <h1>View:</h1>
  
  <pre><code>&lt;?php
  foreach($query as $row)
  {
      print $row-&gt;username;
      print $row-&gt;password;
      print $row-&gt;fname;
      print $row-&gt;lname;
      print $row-&gt;contact;
      print "&lt;br&gt;";
  }
  ?&gt;
  </code></pre>