title: Why affected_rows always returns -1?
body: <p>I seem to have problem getting affected_rows when I INSERT and SELECT, it just returns -1 for some reason? I'm using a database class which I use all the time for my projects which uses MYSQLI prepare statements to avoid SQL injections.</p>
  <p>Does anyone know why it returns -1 all the time? From what I have read it should be able to return affected rows on both INSERT and SELECT.</p>
  <p><strong>Database class</strong></p>
  <pre><code>class database {
      protected $_mysqli;
      protected $_debug;
   
      public function __construct($host, $username, $password, $database, $debug) {
          $this-&gt;_mysqli = new mysqli($host, $username, $password, $database);
          $this-&gt;_debug = (bool) $debug;
          if (mysqli_connect_errno()) {
              if ($this-&gt;_debug) {
                  echo mysqli_connect_error();
                  debug_print_backtrace();
              }
              return false;
          }
          return true;
      }
   
      public function q($query) {
          if ($query = $this-&gt;_mysqli-&gt;prepare($query)) {
              if (func_num_args() &gt; 1) {
                  $x = func_get_args();
                  $args = array_merge(array(func_get_arg(1)),
                      array_slice($x, 2));
                  $args_ref = array();
                  foreach($args as $k =&gt; &amp;$arg) {
                      $args_ref[$k] = &amp;$arg; 
                  }
                  call_user_func_array(array($query, 'bind_param'), $args_ref);
              }
              $query-&gt;execute();
              
              if ($query-&gt;errno) {
                if ($this-&gt;_debug) {
                  echo mysqli_error($this-&gt;_mysqli);
                  debug_print_backtrace();
                }
                return false;
              }
   
              if ($query-&gt;affected_rows &gt; -1) {
                  return $query-&gt;affected_rows;
              }
              $params = array();
              $meta = $query-&gt;result_metadata();
              while ($field = $meta-&gt;fetch_field()) {
                  $params[] = &amp;$row[$field-&gt;name];
              }
              call_user_func_array(array($query, 'bind_result'), $params);
   
              $result = array();
              while ($query-&gt;fetch()) {
                  $r = array();
                  foreach ($row as $key =&gt; $val) {
                      $r[$key] = $val;
                  }
                  $result[] = $r;
              }
              $query-&gt;close(); 
              return $result;
          } else {
              if ($this-&gt;_debug) {
                  echo $this-&gt;_mysqli-&gt;error;
                  debug_print_backtrace();
              }
              return false;
          }
      }
   
      public function handle() {
          return $this-&gt;_mysqli;
      }
      
      public function last_insert_id()
      {
          return $this-&gt;_mysqli-&gt;insert_id;
      }
  
      public function found_rowss()
      {
          return $this-&gt;_mysqli-&gt;affected_rows;
      }
  }
  </code></pre>