title: Error getting results from MySQL database
body: <p>This is my class for connecting to a database but when I create an instance of that class it gives me this error: <code>Fatal error: Call to undefined method DB::query()</code> in C:\Apache24\htdocs\core\DB.class.php on line 21.</p>
  
  <pre><code> &lt;?php
  
  class DB {
      protected $db_name = "data_db";
      protected $db_user = "root";
      protected $db_pass = "root";
      protected $db_host = "localhost";
  
      public function __construct() {
          $db = new mysqli($this-&gt;db_host, $this-&gt;db_user, $this-&gt;db_pass, $this-&gt;db_name);
          if ($db-&gt;connect_errno) {
              printf("Connection failed: %s\n", $db-&gt;connect_error);
              exit();
          } else
              return $db;
      }
  }
  
  $db = new DB();
  
  $data_row = $db-&gt;query("SELECT * FROM `users`");
  while($data = $data_row-&gt;fetch_assoc())
      echo $data["first_name"] . '&lt;br&gt;';
  
  ?&gt;
  </code></pre>
  
  <p>Fatal error: Call to undefined method DB::query() in C:\Apache24\htdocs\core\DB.class.php on line 21</p>