<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pdo.lastinsertid" xmlns="http://docbook.org/ns/docbook">
 <refnamediv>
  <refname>PDO::lastInsertId</refname>
  <refpurpose>
   Returns the ID of the last inserted row or sequence value
  </refpurpose>
 </refnamediv>
 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis role="PDO">
   <modifier>public</modifier> <type class="union"><type>string</type><type>false</type></type><methodname>PDO::lastInsertId</methodname>
   <methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>name</parameter><initializer>&null;</initializer></methodparam>
  </methodsynopsis>

  <para>
   Returns the ID of the last inserted row, or the last value from a
   sequence object, depending on the underlying driver. For example,
   <link linkend="ref.pdo-pgsql">PDO_PGSQL</link> allows the name of any
   sequence object to be specified for the <parameter>name</parameter> parameter.
  </para>
  <note>
   <para>
    This method may not return a meaningful or consistent result across
    different PDO drivers, because the underlying database may not even
    support the notion of auto-increment fields or sequences.
   </para>
  </note>
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <para>
   <variablelist>
    <varlistentry>
     <term><parameter>name</parameter></term>
     <listitem>
      <para>
       Name of the sequence object from which the ID should be returned.
      </para>
     </listitem>
    </varlistentry>
   </variablelist>
  </para>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   If a sequence name was not specified for the <parameter>name</parameter>
   parameter, <methodname>PDO::lastInsertId</methodname> returns a
   string representing the row ID of the last row that was inserted into
   the database.
  </para>
  <para>
   If a sequence name was specified for the <parameter>name</parameter>
   parameter, <methodname>PDO::lastInsertId</methodname> returns a
   string representing the last value retrieved from the specified sequence
   object.
  </para>
  <para>
   If the PDO driver does not support this capability,
   <methodname>PDO::lastInsertId</methodname> triggers an
   <literal>IM001</literal> SQLSTATE.
  </para>
 </refsect1>

 <refsect1 role="errors">
  &reftitle.errors;
  &pdo.errors;
 </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:"~/.phpdoc/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
-->
