title: PHP PDO rowCount() returning -1
body: <p>I need to add a pagination system to my API. My database server is ODBC. My code looks like this:</p>
  <pre><code>public function pagination($query, $maxperpage, $values=array()){
      $query = explode('LIMIT', $query);
      try {
          $statement = $this-&gt;db-&gt;prepare($query[0]);
          $statement-&gt;execute($values);
  
          $result['row_number'] = $statement-&gt;rowCount();
          $result['max_per_page'] = $maxperpage;
          $result['page_nb'] = ceil($result['row_number']/$maxperpage);
          return $result;
      } catch (\PDOException $e) {
          exit($e-&gt;getMessage());
      }
  }
  </code></pre>
  <p>But that gives me the following:</p>
  <pre><code>&quot;pagination&quot;: {
      &quot;row_number&quot;: -1,
      &quot;max_per_page&quot;: &quot;1000&quot;,
      &quot;page_nb&quot;: 0
  }
  </code></pre>
  <p>Why is the row number not working?</p>
  <p>The query looks fine</p>
  <p>SELECT lo_sit, lo_dep, lo_wrh, lo_addr, lo_rotcls, lo_asscls, lo_stotyp, lo_extcod, lo_blccod from G2001F.LOCMSTP WHERE LO_DEP=:lodep</p>
  <p>and the values seems to be inserted fine as well</p>
  <pre><code>Array
  (
      [lodep] =&gt; DEMO
  )
  </code></pre>
  <p>$statement-&gt;rowCount() returning -1 makes no sense.</p>