php-doc-en/reference/pdo/functions/PDO-lastInsertId.xml
2005-03-10 00:02:49 +00:00

121 lines
3.2 KiB
XML

<?xml version='1.0' encoding='iso-8859-1'?>
<!-- $Revision: 1.6 $ -->
<!-- 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
</refpurpose>
</refnamediv>
<refsect1 role="description">
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>PDO::lastInsertId</methodname>
<methodparam choice="opt"><type>string</type><parameter>name</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
Returns the ID of the last inserted row, or the next value from a
sequence object.
</para>
<note>
<para>
Due to differences between database server implementations, this method
may not always return a meaningful result.
</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, <function>PDOStatement::lastInsertId</function> 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, <function>PDOStatement::lastInsertId</function> returns a
string representing the next value retrieved from the specified sequence
object.
</para>
<para>
If the PDO driver does not support this capability,
<function>PDO::lastInsertID</function> triggers an
<literal>IM001</literal> SQLSTATE.
</para>
</refsect1>
<!-- Use when examples exist
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Retrieving the last insert ID</title>
<para>
The following example demonstrates how to use the
<function>PDO::lastInsertID</function> method to retrieve the row
identifier for the last row that has been inserted into the database.
</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>
-->
</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
-->