It's worth noting that calling closeCursor() is usually only required
if you don't explicitly fetch all the rows from a given statement
object before switching to a different statement object.

In other words:

$stmt->execute();
$stmt->fetch();
$stmt->execute();

will work happily, but

$stmt->execute();
$stmt->fetch();
$otherStmt->execute();

might break with an out-of-sequence error for some drivers.
Adding a $stmt->closeCursor() before $otherStmt->fetch() is one way to
handle this situation.


On 7/9/05, Dan Scott <[EMAIL PROTECTED]> wrote:
> dbs             Sat Jul  9 01:19:02 2005 EDT
> 
>   Added files:
>     /phpdoc/en/reference/pdo/functions  PDOStatement-closeCursor.xml
> 
>   Modified files:
>     /phpdoc/en/reference/pdo    reference.xml
>     /phpdoc/en/reference/pdo/functions  PDO-lastInsertId.xml
>   Log:
>   PDO-lastInsertID() returns last value of sequence object.
>   Document PDOStatement-closeCursor().
> 
> 
> http://cvs.php.net/diff.php/phpdoc/en/reference/pdo/reference.xml?r1=1.23&r2=1.24&ty=u
> Index: phpdoc/en/reference/pdo/reference.xml
> diff -u phpdoc/en/reference/pdo/reference.xml:1.23 
> phpdoc/en/reference/pdo/reference.xml:1.24
> --- phpdoc/en/reference/pdo/reference.xml:1.23  Fri Jun  3 08:54:13 2005
> +++ phpdoc/en/reference/pdo/reference.xml       Sat Jul  9 01:19:00 2005
> @@ -1,5 +1,5 @@
>  <?xml version='1.0' encoding='iso-8859-1'?>
> -<!-- $Revision: 1.23 $ -->
> +<!-- $Revision: 1.24 $ -->
>  <!-- Generated by xml_proto.php v2.1. Found in /scripts directory of phpdoc. 
> -->
>   <reference id="ref.pdo">
>    <title>PDO Functions</title>
> @@ -326,6 +326,12 @@
>         </listitem>
>         <listitem>
>          <para>
> +         <link linkend='function.PDOStatement-closeCursor'>closeCursor</link>
> +         - closes the cursor, allowing the statement to be executed again
> +        </para>
> +       </listitem>
> +       <listitem>
> +        <para>
>           <link linkend='function.PDOStatement-columnCount'>columnCount</link>
>           - returns the number of columns in the result set
>          </para>
> http://cvs.php.net/diff.php/phpdoc/en/reference/pdo/functions/PDO-lastInsertId.xml?r1=1.6&r2=1.7&ty=u
> Index: phpdoc/en/reference/pdo/functions/PDO-lastInsertId.xml
> diff -u phpdoc/en/reference/pdo/functions/PDO-lastInsertId.xml:1.6 
> phpdoc/en/reference/pdo/functions/PDO-lastInsertId.xml:1.7
> --- phpdoc/en/reference/pdo/functions/PDO-lastInsertId.xml:1.6  Wed Mar  9 
> 19:02:49 2005
> +++ phpdoc/en/reference/pdo/functions/PDO-lastInsertId.xml      Sat Jul  9 
> 01:19:01 2005
> @@ -1,11 +1,11 @@
>  <?xml version='1.0' encoding='iso-8859-1'?>
> -<!-- $Revision: 1.6 $ -->
> +<!-- $Revision: 1.7 $ -->
>  <!-- Generated by xml_proto.php v2.1. Found in /scripts directory of phpdoc. 
> -->
>    <refentry id="function.PDO-lastInsertId">
>     <refnamediv>
>      <refname>PDO::lastInsertId</refname>
>      <refpurpose>
> -     Returns the ID of the last inserted row
> +     Returns the ID of the last inserted row or sequence value
>      </refpurpose>
>     </refnamediv>
>     <refsect1 role="description">
> @@ -18,7 +18,7 @@
>      &warn.experimental.func;
> 
>      <para>
> -     Returns the ID of the last inserted row, or the next value from a
> +     Returns the ID of the last inserted row, or the last value from a
>       sequence object.
>      </para>
>      <note>
> @@ -56,7 +56,7 @@
>      <para>
>       If a sequence name was specified for the <parameter>name</parameter>
>       parameter, <function>PDOStatement::lastInsertId</function> returns a
> -     string representing the next value retrieved from the specified sequence
> +     string representing the last value retrieved from the specified sequence
>       object.
>      </para>
>      <para>
> 
> http://cvs.php.net/co.php/phpdoc/en/reference/pdo/functions/PDOStatement-closeCursor.xml?r=1.1&p=1
> Index: phpdoc/en/reference/pdo/functions/PDOStatement-closeCursor.xml
> +++ phpdoc/en/reference/pdo/functions/PDOStatement-closeCursor.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-closeCursor">
>  <refnamediv>
>   <refname>PDOStatement::closeCursor</refname>
>   <refpurpose>
>    Closes the cursor, enabling the statement to be executed again.
>   </refpurpose>
>  </refnamediv>
>  <refsect1 role="description">
>   &reftitle.description;
>   <methodsynopsis>
>    <type>bool</type><methodname>PDOStatement::closeCursor</methodname>
>    <void/>
>   </methodsynopsis>
> 
>   &warn.experimental.func;
> 
>   <para>
>    <function>PDOStatement::closeCursor</function> frees up the connection
>    to the server so that other queries may be issued, but leaves the
>    statement in a state that enables it to be executed again.
>   </para>
>   <para>
>    This 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.
>   </para>
>   <para>
>    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>
> 
>  <!-- Use when EXCEPTIONS exist
>  <refsect1 role="exceptions">
>   &reftitle.exceptions;
>   <para>
>    When does this function throw exceptions?
>   </para>
>  </refsect1>
>  -->
> 
> 
>  <!-- Use when a CHANGELOG exists
>  <refsect1 role="changelog">
>   &reftitle.changelog;
>   <para>
>    <informaltable>
>     <tgroup cols="2">
>      <thead>
>       <row>
>        <entry>&Version;</entry>
>        <entry>&Description</entry>
>       </row>
>      </thead>
>      <tbody>
>       <row>
>        <entry>Enter the PHP version of change here
>        <entry>Description of change
>       </row>
>      </tbody>
>     </tgroup>
>    </informaltable>
>   </para>
>  </refsect1>
>  -->
> 
> 
>  <!-- Use when examples exist
>  <refsect1 role="examples">
>   &reftitle.examples;
>   <para>
>    <example>
>     <title>A <function>PDOStatement::closeCursor</function> example</title>
>     <para>
>      Any text that describes the purpose of the example, or
>      what goes on in the example should go here (inside the
>      <example> tag, not out
>     </para>
>     <programlisting role="php">
> <![CDATA[
> <?php
> if ($anexample === true) {
>     echo 'Use the PEAR Coding Standards';
> }
> ?>
> ]]>
>     </programlisting>
>     &example.outputs;
>     <screen>
> <![CDATA[
> Use the PEAR Coding Standards
> ]]>
>     </screen>
>    </example>
>   </para>
>  </refsect1>
>  -->
> 
> 
>  <refsect1 role="seealso">
>   &reftitle.seealso;
>   <para>
>    <simplelist>
>     <member><function>PDOStatement::execute</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
> -->
>

Reply via email to