Sophie

Sophie

distrib > Mageia > 7 > x86_64 > by-pkgid > 2b917e0437961edec048f1d15e2d7449 > files > 11278

php-manual-en-7.2.11-1.mga7.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Returns metadata for a column in a result set</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="pdostatement.getattribute.html">PDOStatement::getAttribute</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="pdostatement.nextrowset.html">PDOStatement::nextRowset</a></div>
 <div class="up"><a href="class.pdostatement.html">PDOStatement</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><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, 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="type">array</span> <span class="methodname"><strong>PDOStatement::getColumnMeta</strong></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$column</code></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">
    Not all PDO drivers support
    <span class="function"><strong>PDOStatement::getColumnMeta()</strong></span>.
   </p>
  </div>

  <p class="para">The following drivers support this method:</p>
  <ul class="itemizedlist">
   <li class="listitem"><span class="simpara"><a href="ref.pdo-dblib.html" class="link">PDO_DBLIB</a></span></li>
   <li class="listitem"><span class="simpara"><a href="ref.pdo-mysql.html" class="link">PDO_MYSQL</a></span></li>
   <li class="listitem"><span class="simpara"><a href="ref.pdo-pgsql.html" class="link">PDO_PGSQL</a></span></li>
   <li class="listitem"><span class="simpara"><a href="ref.pdo-sqlite.html" class="link">PDO_SQLITE</a></span></li>
  </ul>

 </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><em>native_type</em></td>
       <td>The PHP native type used to represent the column value.</td>
      </tr>

      <tr>
       <td><em>driver:decl_type</em></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="function"><strong>PDOStatement::getColumnMeta()</strong></span>.
       </td>
      </tr>

      <tr>
       <td><em>flags</em></td>
       <td>Any flags set for this column.</td>
      </tr>

      <tr>
       <td><em>name</em></td>
       <td>The name of this column as returned by the database.</td>
      </tr>

      <tr>
       <td><em>table</em></td>
       <td>The name of this column&#039;s table as returned by the database.</td>
      </tr>

      <tr>
       <td><em>len</em></td>
       <td>The length of this column. Normally <em>-1</em> for
       types other than floating point decimals.</td>
      </tr>

      <tr>
       <td><em>precision</em></td>
       <td>The numeric precision of this column. Normally
       <em>0</em> for types other than floating point
       decimals.</td>
      </tr>

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

     </tbody>
    
   </table>

  <p class="para">
   Returns <strong><code>FALSE</code></strong> if the requested column does not exist in the result set,
   or if no result set exists.
  </p>
 </div>


 

 <div class="refsect1 changelog" id="refsect1-pdostatement.getcolumnmeta-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>5.4.0</td>
       <td><a href="ref.pdo-dblib.html" class="link">PDO_DBLIB</a> driver support added</td>
      </tr>

      <tr>
       <td>5.2.3</td>
       <td><em>table</em> field</td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-pdostatement.getcolumnmeta-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-1080">
    <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&nbsp;</span><span style="color: #007700">=&nbsp;</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&nbsp;COUNT(*)&nbsp;FROM&nbsp;fruit'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$meta&nbsp;</span><span style="color: #007700">=&nbsp;</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="cdata"><pre>
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 class="member"><span class="function"><a href="pdostatement.columncount.html" class="function" rel="rdfs-seeAlso">PDOStatement::columnCount()</a> - Returns the number of columns in the result set</span></li>
    <li class="member"><span class="function"><a href="pdostatement.rowcount.html" class="function" rel="rdfs-seeAlso">PDOStatement::rowCount()</a> - Returns the number of rows affected by the last SQL statement</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="pdostatement.getattribute.html">PDOStatement::getAttribute</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="pdostatement.nextrowset.html">PDOStatement::nextRowset</a></div>
 <div class="up"><a href="class.pdostatement.html">PDOStatement</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>