title: Why is PDOStatement->columnCount not returning the right number?
body: <p>I'm querying the database first to get all records associated with a certain userid, then i need to go in and modify the array, because one of the fields is an id and i need the name associated with that id.</p>
  
  <p>So i use columnCount to iterate through the resulting array at the index of the id and replace it with the right name, which works fine, for the first six results. columnCount only returns 6, but those first six are renamed as they should be. But outside of that it takes the results from that pdostatement and populates the table normally, with all the relevant data, 17 rows right now.</p>
  
  <p>Why is it returning 6, or what am i doing to get that wrong columncount?</p>
  
  <pre><code>global $__CMS_CONN__;
      $timeqry = 'SELECT facility_id, program, date, visit_length, mileage, served FROM timesheet_db WHERE volunteer_id = '.$_SESSION['user_id'];
      $stmt = $__CMS_CONN__-&gt;prepare($timeqry);
      $stmt-&gt;execute();
      $columns = $stmt-&gt;columnCount();
      print $columns;
      if($stmt)
      {
          $arrValues = $stmt-&gt;fetchAll(PDO::FETCH_ASSOC);
  
          for($x=0;$x&lt;$stmt-&gt;columnCount();$x++)
          {
              global $__CMS_CONN__;
              $qry = 'SELECT facility FROM facility_db WHERE id = '.$arrValues[$x]['facility_id'];
              $stmt1 = $__CMS_CONN__-&gt;prepare($qry);
              $stmt1-&gt;execute();
              if($stmt1)
              {
                  $facilityName = $stmt1-&gt;fetchAll(PDO::FETCH_ASSOC);
                  foreach ($facilityName as $item)
                  {
                      foreach ($item as $key =&gt; $val)
                      {
                          $arrValues[$x]['facility_id'] = $val;
                      }
                  }
              }
          }
          print "&lt;table style=\"font-size:90%\"&gt;\n";
          print "&lt;tr&gt;\n";
          print "&lt;th style=\"width:100%\"&gt;Facility&lt;/th&gt;";
          print "&lt;th&gt;Program&lt;/th&gt;";
          print "&lt;th&gt;Date&lt;/th&gt;";
          print "&lt;th&gt;Visit Length&lt;/th&gt;";
          print "&lt;th&gt;Mileage&lt;/th&gt;";
          print "&lt;th&gt;Served&lt;/th&gt;";
          print "&lt;/tr&gt;";
          foreach ($arrValues as $row)
          {
              print "&lt;tr&gt;";
              foreach ($row as $key =&gt; $val)
              {
                  print "&lt;td&gt;$val&lt;/td&gt;";
              }
              print "&lt;/tr&gt;\n";
          }
          print "&lt;/table&gt;\n";
      }
  </code></pre>