<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.pdostatement.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'pdostatement.getcolumnmeta.php',
    1 => 'PDOStatement::getColumnMeta',
    2 => 'Returns metadata for a column in a result set',
  ),
  'up' => 
  array (
    0 => 'class.pdostatement.php',
    1 => 'PDOStatement',
  ),
  'prev' => 
  array (
    0 => 'pdostatement.getattribute.php',
    1 => 'PDOStatement::getAttribute',
  ),
  'next' => 
  array (
    0 => 'pdostatement.getiterator.php',
    1 => 'PDOStatement::getIterator',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/pdo/pdostatement/getcolumnmeta.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="pdostatement.getcolumnmeta" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">PDOStatement::getColumnMeta</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.1.0, PHP 7, PHP 8, PECL pdo &gt;= 0.2.0)</p><p class="refpurpose"><span class="refname">PDOStatement::getColumnMeta</span> &mdash; <span class="dc-title">
   Returns metadata for a column in a result set
  </span></p>

 </div>
 <div class="refsect1 description" id="refsect1-pdostatement.getcolumnmeta-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>PDOStatement::getColumnMeta</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$column</code></span>): <span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  
  <p class="para rdfs-comment">
   Retrieves the metadata for a 0-indexed column in a result set as an
   associative array.
  </p>
  <div class="warning"><strong class="warning">Warning</strong>
   <p class="simpara">
    Some drivers may not implement
    <span class="methodname"><strong>PDOStatement::getColumnMeta()</strong></span>,
    as it is optional. However, all
    <a href="pdo.drivers.php" class="link">PDO drivers</a>
    documented in the manual implement this function.
   </p>
  </div>

 </div>

 <div class="refsect1 parameters" id="refsect1-pdostatement.getcolumnmeta-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">column</code></dt>
      <dd>
       <p class="para">
        The 0-indexed column in the result set.
       </p>
      </dd>
     
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-pdostatement.getcolumnmeta-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns an associative array containing the following values representing
   the metadata for a single column:
  </p>
   <table class="doctable table">
    <caption><strong>Column metadata</strong></caption>
    
     <col /> 
     <col /> 
     <thead>
      <tr>
       <th>Name</th>
       <th>Value</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td><code class="literal">native_type</code></td>
       <td>The PHP native type used to represent the column value.</td>
      </tr>

      <tr>
       <td><code class="literal">driver:decl_type</code></td>
       <td>The SQL type used to represent the column value in the database.
       If the column in the result set is the result of a function, this value
       is not returned by <span class="methodname"><strong>PDOStatement::getColumnMeta()</strong></span>.
       </td>
      </tr>

      <tr>
       <td><code class="literal">flags</code></td>
       <td>Any flags set for this column.</td>
      </tr>

      <tr>
       <td><code class="literal">name</code></td>
       <td>The name of this column as returned by the database.</td>
      </tr>

      <tr>
       <td><code class="literal">table</code></td>
       <td>The name of this column&#039;s table as returned by the database.</td>
      </tr>

      <tr>
       <td><code class="literal">len</code></td>
       <td>The length of this column. Normally <code class="literal">-1</code> for
       types other than floating point decimals.</td>
      </tr>

      <tr>
       <td><code class="literal">precision</code></td>
       <td>The numeric precision of this column. Normally
       <code class="literal">0</code> for types other than floating point
       decimals.</td>
      </tr>

      <tr>
       <td><code class="literal">pdo_type</code></td>
       <td>The type of this column as represented by the
       <a href="pdo.constants.php" class="link"><code class="literal">PDO::PARAM_*</code>
       constants</a>.</td>
      </tr>

     </tbody>
    
   </table>

  <p class="para">
   Returns <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> if the requested column does not exist in the result set,
   or if no result set exists.
  </p>
 </div>


 

 <div class="refsect1 examples" id="refsect1-pdostatement.getcolumnmeta-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 Retrieving column metadata</strong></p>
    <div class="example-contents"><p>
     The following example shows the results of retrieving the metadata for a
     single column generated by a function (COUNT) in a PDO_SQLITE driver.
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$select </span><span style="color: #007700">= </span><span style="color: #0000BB">$DB</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">'SELECT COUNT(*) FROM fruit'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$meta </span><span style="color: #007700">= </span><span style="color: #0000BB">$select</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getColumnMeta</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$meta</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">array(6) {
  [&quot;native_type&quot;]=&gt;
  string(7) &quot;integer&quot;
  [&quot;flags&quot;]=&gt;
  array(0) {
  }
  [&quot;name&quot;]=&gt;
  string(8) &quot;COUNT(*)&quot;
  [&quot;len&quot;]=&gt;
  int(-1)
  [&quot;precision&quot;]=&gt;
  int(0)
  [&quot;pdo_type&quot;]=&gt;
  int(2)
}</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-pdostatement.getcolumnmeta-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="methodname"><a href="pdostatement.columncount.php" class="methodname" rel="rdfs-seeAlso">PDOStatement::columnCount()</a> - Returns the number of columns in the result set</span></li>
    <li><span class="methodname"><a href="pdostatement.rowcount.php" class="methodname" rel="rdfs-seeAlso">PDOStatement::rowCount()</a> - Returns the number of rows affected by the last SQL statement</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>