title: no error retuns in the mysql error method
body: <p>I have a php/mysql database class as in below code. I am failing to get any mysql error from the error method when there is an error in the mysql query. guide me if anything wrong here. if i used non oop method to query same thing, then i can get the expected error from that. but nothing from this class.</p>
  
  <pre><code>class db {
      protected static $connection;
  
      var $hostname;
      var $username;
      var $password;
      var $database;
  
      public function __construct() {
          $this-&gt;hostname = "localhost";
          $this-&gt;username = "root";
          $this-&gt;password = "";
          $this-&gt;database = "my_db";
      }
  
      public function connect() {    
          if(!isset(self::$connection)) {               
              self::$connection = new mysqli($this-&gt;hostname,$this-&gt;username,$this-&gt;password,$this-&gt;database);
          }
  
          // If connection was not successful, handle the error
          if(self::$connection === false) {
              // Handle error - notify administrator, log to a file, show an error screen, etc.
              return false;
          }
  
          self::$connection -&gt; query("SET NAMES 'utf8'");
  
          return self::$connection;
      }
  
  
      public function query($query) {
          // Connect to the database
          $connection = $this -&gt; connect();
          // Query the database
          $result = $connection -&gt; query($query);
  
          return $result;
      }
  
      public function multi_query($query){
          // Connect to the database
          $connection = $this -&gt; connect();
  
          // Query the database
          $result = $connection -&gt; multi_query($query);
  
          return $result;
      }
  
      public function insert($query) {
          // Connect to the database
          $connection = $this -&gt; connect();
  
          // Query the database
          $connection -&gt; query($query);
          // Get inserted id
          $insertid = $connection -&gt; insert_id;
  
          return $insertid;
      }
  
      public function select($query) {
          $rows = array();
          $result = $this -&gt; query($query);
          if($result === false) {
              return false;
          }
          while ($row = $result -&gt; fetch_assoc()) {
              $rows[] = $row;
          }
          return $rows;
      }
  
      public function num_rows($query) {
          $result = $this -&gt; query($query);
  
          if($result === false) {
              $count = 0;
          }
          else $count = $result-&gt;num_rows;
  
          return $count;
      }
  
      /**
       * Fetch the last error from the database
       * 
       * @return string Database error message
       */
      public function error() {
          $connection = $this -&gt; connect();
          return $connection -&gt; error;
      }
  
      /**
       * Quote and escape value for use in a database query
       *
       * @param string $value The value to be quoted and escaped
       * @return string The quoted and escaped string
       */
      public function escape($value) {
          $connection = $this -&gt; connect();
          return $connection -&gt; real_escape_string(trim($value));
      }
  }
  </code></pre>
  
  <p>i am expecting the error from this method. but i am not getting any error when there is an error from mysql query.</p>
  
  <pre><code>public function error() {
      $connection = $this -&gt; connect();
      return $connection -&gt; error;
  }
  </code></pre>
  
  <p>Below example table has, id (Auto Increment), and three other fields VARCHAR (3). If I run below php, no error details coming, even though there's an obvious mismatch between the number of columns in the respective parts of the query...</p>
  
  <pre><code>    &lt;?php
      include('class.db.php');
  
      $query = "INSERT INTO abc_table (`a`,`b`,`c`) VALUES ('a','b','c','d')";
      $insert_id = $db-&gt;insert($query);
      if($insert_id&gt;0){
          echo "Insert Success !";
      }
      else echo "Insert Failed. ".$db-&gt;error();
      ?&gt;
  </code></pre>