php-doc-en/reference/cubrid/functions/cubrid-insert-id.xml
2010-09-07 02:24:05 +00:00

106 lines
3.3 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.cubrid-insert-id" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_insert_id</refname>
<refpurpose>Returns an array with the IDs generated for the <constant>AUTO_INCREMENT</constant> columns</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>array</type><methodname>cubrid_insert_id</methodname>
<methodparam><type>string</type><parameter>class_name</parameter></methodparam>
<methodparam choice="opt"><type>resource</type><parameter>conn_identifier</parameter></methodparam>
</methodsynopsis>
<para>
This function returns an array with the IDs generated for the <constant>AUTO_INCREMENT</constant> columns that were updated by the previous INSERT query. It returns an array with all the <constant>AUTO_INCREMENT</constant> columns and their values. It returns 0 if the previous query does not generate new rows, or it returns FALSE on failure.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>class_name</parameter></term>
<listitem><para>The name of the class (table) that was used in the last INSERT statement for which the auto increment values are retrieved.</para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>conn_identifier</parameter></term>
<listitem><para>The connection identifier previously obtained by a call to <function>cubrid_connect</function>.</para></listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
An associative array with all the AUTO_INCREMENT columns and their values, on success.
</para>
<para>
0, if the previous query does not generate new rows.
</para>
<para>
&false; on failure.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<title><function>cubrid_insert_id</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$link = cubrid_connect("localhost", 30000, "demodb2", "dba", "");
if (!$link)
{
die('Could not connect.');
}
$query = "insert into employees (name, address, salary) values ('Michael', 'Boston, MA', 3750)";
$result = cubrid_execute($link, $query);
if ($result)
{
$array_id = cubrid_insert_id("employees");
echo "Last insert id was ".$array_id["id"];
cubrid_close_request($result);
}
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Result:
Last insert id was 10
]]>
</screen>
</example>
</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
-->