php-doc-en/reference/pdo/functions/PDOStatement-columnCount.xml
Hannes Magnusson c030e2adf7 Upgrade to DocBook5:
- All id attributes are now xml:id
 - Add docbook namespace to all root elements
 - Replace <ulink /> with <link xlink:href />
 - Minor markup fixes here and there


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@238160 c90b9560-bf6c-de11-be94-00142212c4b1
2007-06-20 22:25:43 +00:00

117 lines
3.2 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<refentry xml:id="function.PDOStatement-columnCount" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>PDOStatement->columnCount()</refname>
<refpurpose>
Returns the number of columns in the result set
</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<classsynopsis>
<ooclass><classname>PDOStatement</classname></ooclass>
<methodsynopsis>
<type>int</type><methodname>columnCount</methodname>
<void/>
</methodsynopsis>
</classsynopsis>
<para>
Use <xref linkend="function.PDOStatement-columnCount" /> to return the number
of columns in the result set represented by the PDOStatement object.
</para>
<para>
If the PDOStatement object was returned from <xref linkend="function.PDO-query" />,
the column count is immediately available.
</para>
<para>
If the PDOStatement object was returned from
<xref linkend="function.PDO-prepare" />, an accurate column count will not be
available until you invoke <xref linkend="function.PDOStatement-execute" />.
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns the number of columns in the result set represented by the
PDOStatement object. If there is no result set,
<xref linkend="function.PDOStatement-columnCount" /> returns <literal>0</literal>.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Counting columns</title>
<para>
This example demonstrates how <xref linkend="function.PDOStatement-columnCount" />
operates with and without a result set.
</para>
<programlisting role="php">
<![CDATA[
<?php
$dbh = new PDO('odbc:sample', 'db2inst1', 'ibmdb2');
$sth = $dbh->prepare("SELECT name, colour FROM fruit");
/* Count the number of columns in the (non-existent) result set */
$colcount = $sth->columnCount();
print("Before execute(), result set has $colcount columns (should be 0)\n");
$sth->execute();
/* Count the number of columns in the result set */
$colcount = $sth->columnCount();
print("After execute(), result set has $colcount columns (should be 2)\n");
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Before execute(), result set has 0 columns (should be 0)
After execute(), result set has 2 columns (should be 2)
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><xref linkend="function.PDO-prepare" /></member>
<member><xref linkend="function.PDOStatement-execute" /></member>
<member><xref linkend="function.PDOStatement-rowCount" /></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->