title: PHP Mysqli statement returns a single row, -1 rows affected, and no error
body: <p>This is so baffling I MUST be missing something simple. I have a query that checks to see if the transaction I'm inserting already exists in order to prevent duplicates. Here's the code:</p>
  
  <pre><code>function isaDupe($portableDB, $transactArray)
  {
      $ref = $transactArray["reference"];
      $date = $transactArray["qdate"];
      $time =  $transactArray["time"];
  
    //prints the query so I can run by hand to test
      print "SELECT `counter` FROM transactions WHERE (`reference` = '$ref' AND `qdate` = '$date' AND `time` = '$time') ";
  
      if ($dupeSelectStmt = $portableDB-&gt;prepare("SELECT `counter` FROM transactions WHERE (`reference` = ? AND `qdate` = ? AND `time` = ?)"))
      {
          $dupeSelectStmt-&gt;bind_param('sss',$ref, $date, $time);
          $dupeSelectStmt-&gt;bind_result($counter);
          $dupeSelectStmt-&gt;execute();
  
          while ($dupeSelectStmt-&gt;fetch())
          {
              break;
          }
  
          $numRows = $portableDB-&gt;affected_rows;
  
          if ($numRows &gt; 0)
              return TRUE;
          else if ($numRows == -1)
          {
              print " ERROR: ";
              print_r($portableDB-&gt;error);
              print_r($dupeSelectStmt-&gt;error);
              return FALSE;
          }
          else
              return FALSE;
      }
  }
  </code></pre>
  
  <p>-If I run the query by hand through Workbench on the same server, I get 24 rows returned.</p>
  
  <p>--this is the same if I prepare, set, and execute the statement by hand.</p>
  
  <p>-affected_rows returns -1</p>
  
  <p>--same if I do num_rows on the statement</p>
  
  <p>-there is no error stored on the Statement or MySQLi object.</p>
  
  <p>-if I put a print in the fetch() statement, it prints one row's worth of data</p>
  
  <p>-if I store the fetched rows into an array and count the results, it's 1</p>
  
  <p>-I've tried running it with each variable separately, same thing.</p>
  
  <p>-other queries on the same server (heck, on the same MySQLi object) are working fine. SELECTS, UPDATES, and INSERTS.</p>