title: PHP odbc_fetch_row VERY SLOW
body: <p>In summary, when using odbc_fetch_row() with SQL Server 2012 in PHP it takes 17 seconds to loop through 525 results.</p>
  
  <p>Environment:</p>
  
  <ul>
  <li>Mac OS X 10.9</li>
  <li>Apache (that ships with os x)</li>
  <li>PHP 5.5.8 from <a href="http://php-osx.liip.ch/" rel="nofollow">http://php-osx.liip.ch/</a></li>
  <li>ODBC Driver: Actual SQL Server</li>
  <li>SQL Server 2012</li>
  </ul>
  
  <p>odbc.ini file contents:</p>
  
  <pre><code>[ODBC Data Sources]
  theDb           = Actual SQL Server
  
  [theDb]
  Driver         = /Library/ODBC/Actual SQL Server.bundle/Contents/MacOS/atsqlsrv.so
  Description    = Production SQL Server
  Server         = [some address]
  Database       = [some db]
  ServerName     = theDb
  host           = [some address]
  </code></pre>
  
  <p>PHP Test Page:</p>
  
  <pre><code>&lt;?php
  
  $userID="[user]";
  $password="[password]";
  $driverSourceString="theDb";
  
  $dbc = odbc_connect($driverSourceString, $userID, $password);
  
  $time_start=0;
  
  function startTimer(){
      global $time_start;
      $time_start = microtime(true);
  }
  
  function printTimer(){
      global $time_start;
      $time_end = microtime(true);
      $time = $time_end - $time_start;
      echo sprintf('%f', $time);
      echo " Seconds";
  }
  
  ?&gt;
  
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;SQL TEST&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
      &lt;pre&gt;
  
      Connection:
      &lt;?php
          startTimer();
          $dbc = odbc_connect($driverSourceString, $userID, $password);
          printTimer();
      ?&gt;
  
  
      Query:
      &lt;?php
          startTimer();
          $query = "SELECT m.firstName + ' ' + m.lastName AS username FROM models m ORDER BY lastName ASC";
          $result = odbc_exec($dbc, $query);
          printTimer();
      ?&gt;
  
  
      Fetchrow:
      &lt;?php
          startTimer();
          while(odbc_fetch_row($result))
          {
              //do nothing
          }
          printTimer();
      ?&gt;
  
      &lt;/pre&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>Connection:
  0.000129 Seconds
  
  Query:
  0.061282 Seconds
  
  Fetchrow:
  15.795249 Seconds (WHY SO LONG??)
  </code></pre>