mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-27 06:18:56 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@184044 c90b9560-bf6c-de11-be94-00142212c4b1
129 lines
3.1 KiB
XML
129 lines
3.1 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.1 $ -->
|
|
<!-- Generated by xml_proto.php v2.2. Found in /scripts directory of phpdoc. -->
|
|
<refentry id="function.PDOStatement-nextRowset">
|
|
<refnamediv>
|
|
<refname>PDOStatement::nextRowset</refname>
|
|
<refpurpose>
|
|
Advances to the next rowset in a multi-rowset statement handle
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>PDOStatement::nextRowset</methodname>
|
|
<void/>
|
|
</methodsynopsis>
|
|
|
|
&warn.experimental.func;
|
|
|
|
<para>
|
|
Some database servers support stored procedures that return more than one
|
|
rowset (also known as a result set).
|
|
<function>PDOStatement::nextRowSet</function> enables you to access the
|
|
second and subsequent rowsets associated with a PDOStatement object. Each
|
|
rowset can have a different set of columns from the preceding rowset.
|
|
</para>
|
|
|
|
</refsect1>
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
&return.success;
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Fetching multiple rowsets returned from a stored procedure</title>
|
|
<para>
|
|
The following example shows how to call a stored procedure,
|
|
MULTIPLE_RESULTS, that returns three rowsets. We use a do / while loop to
|
|
loop over the <function>PDOStatement::nextRowset</function> method, which
|
|
returns false and terminates the loop when no more rowsets can be returned.
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$sql = 'CALL multiple_rowsets()';
|
|
$stmt = $conn->query($sql);
|
|
$i = 1;
|
|
do {
|
|
$rowset = $stmt->fetchAll(PDO_FETCH_NUM);
|
|
if ($rowset) {
|
|
printResultSet($rowset, $i);
|
|
}
|
|
$i++;
|
|
} while ($stmt->nextRowset());
|
|
|
|
function printResultSet(&$rowset, $i) {
|
|
print "Result set $i:\n";
|
|
foreach ($rowset as $row) {
|
|
foreach ($row as $col) {
|
|
print $col . "\t";
|
|
}
|
|
print "\n";
|
|
}
|
|
print "\n";
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
Result set 1:
|
|
apple red
|
|
banana yellow
|
|
|
|
Result set 2:
|
|
orange orange 150
|
|
banana yellow 175
|
|
|
|
Result set 3:
|
|
lime green
|
|
apple red
|
|
banana yellow
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>PDOStatement::columnCount</function></member>
|
|
<member><function>PDOStatement::execute</function></member>
|
|
<member><function>PDOStatement::getColumnMeta</function></member>
|
|
<member><function>PDOStatement::query</function></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
|
|
-->
|