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

- 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
131 lines
3.6 KiB
XML
131 lines
3.6 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.11 $ -->
|
|
<refentry xml:id="function.PDOStatement-closeCursor" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>PDOStatement->closeCursor()</refname>
|
|
<refpurpose>
|
|
Closes the cursor, enabling the statement to be executed again.
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<classsynopsis>
|
|
<ooclass><classname>PDOStatement</classname></ooclass>
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>closeCursor</methodname>
|
|
<void/>
|
|
</methodsynopsis>
|
|
</classsynopsis>
|
|
|
|
<para>
|
|
<xref linkend="function.PDOStatement-closeCursor" /> frees up the connection
|
|
to the server so that other SQL statements may be issued, but leaves the
|
|
statement in a state that enables it to be executed again.
|
|
</para>
|
|
<para>
|
|
This method is useful for database drivers that do not support executing
|
|
a PDOStatement object when a previously executed PDOStatement object still
|
|
has unfetched rows. If your database driver suffers from this limitation,
|
|
the problem may manifest itself in an out-of-sequence error.
|
|
</para>
|
|
<para>
|
|
<xref linkend="function.PDOStatement-closeCursor" /> is implemented either as an
|
|
optional driver specific method (allowing for maximum efficiency), or as
|
|
the generic PDO fallback if no driver specific function is installed.
|
|
The PDO generic fallback is semantically the same as writing the following
|
|
code in your PHP script:
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
do {
|
|
while ($stmt->fetch())
|
|
;
|
|
if (!$stmt->nextRowset())
|
|
break;
|
|
} while (true);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
&return.success;
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>A <xref linkend="function.PDOStatement-closeCursor" /> example</title>
|
|
<para>
|
|
In the following example, the <varname>$stmt</varname> PDOStatement
|
|
object returns multiple rows but the application fetches only the first
|
|
row, leaving the PDOStatement object in a state of having unfetched rows.
|
|
To ensure that the application will work with all database drivers, the
|
|
author inserts a call to <xref linkend="function.PDOStatement-closeCursor" />
|
|
on <varname>$stmt</varname> before executing the
|
|
<varname>$otherStmt</varname> PDOStatement object.
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
/* Create a PDOStatement object */
|
|
$stmt = $dbh->prepare('SELECT foo FROM bar');
|
|
|
|
/* Create a second PDOStatement object */
|
|
$otherStmt = $dbh->prepare('SELECT foobaz FROM foobar');
|
|
|
|
/* Execute the first statement */
|
|
$stmt->execute();
|
|
|
|
/* Fetch only the first row from the results */
|
|
$stmt->fetch();
|
|
|
|
/* The following call to closeCursor() may be required by some drivers */
|
|
$stmt->closeCursor();
|
|
|
|
/* Now we can execute the second statement */
|
|
$otherStmt->execute();
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><xref linkend="function.PDOStatement-execute" /></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
|
|
-->
|