Files
doc-fr/reference/maxdb/functions/maxdb-insert-id.xml
T
Yannick Torres 107d3b624b syn with EN
git-svn-id: https://svn.php.net/repository/phpdoc/fr/trunk@260753 c90b9560-bf6c-de11-be94-00142212c4b1
2008-06-04 22:05:34 +00:00

149 lines
4.2 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.8 $ -->
<!-- EN-Revision: 1.6 Maintainer: yannick Status: ready -->
<!-- Reviewed: no -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.maxdb-insert-id">
<refnamediv>
<refname>maxdb_insert_id</refname>
<refname>maxdb->insert_id</refname>
<refpurpose>Retourne le dernier identifiant généré automatiquement par la dernière requête</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<para>Style procédural :</para>
<methodsynopsis>
<type>mixed</type><methodname>maxdb_insert_id</methodname>
<methodparam><type>resource</type><parameter>link</parameter></methodparam>
</methodsynopsis>
<para>Style orienté objet (propriété) :</para>
<classsynopsis>
<ooclass><classname>maxdb</classname></ooclass>
<fieldsynopsis><type>mixed</type><varname>insert_id</varname></fieldsynopsis>
</classsynopsis>
<para>
<function>maxdb_insert_id</function> retourne le denier identifiant
généré par une requête sur une table qui a une colonne possédant
l'attribut DEFAULT SERIAL. Si la dernière requête n'était pas une requête
de type INSERT ou UPDATE ou si la table modifiée n'a pas de colonne possédant
un attribut DEFAULT SERIAL, cette fonction retournera zéro.
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
La valeur du champs <literal>DEFAULT SERIAL</literal> qui a été
mis à jour par la dernière requête. Retourne zéro s'il n'y a aucune requête
précédente sur la connexion ou si la requête n'a pas mis à jour
la valeur <literal>DEFAULT_SERIAL</literal>.
</para>
<note>
<para>
Si le nombre généré est plus grand que la valeur maximale pour un entier,
<function>maxdb_insert_id</function> retournera une chaîne de caractères.
</para>
</note>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<title>Style orienté objet</title>
<programlisting role="php">
<![CDATA[
<?php
$maxdb = new maxdb("localhost", "MONA", "RED", "DEMODB");
/* Vérification de la connexion */
if (maxdb_connect_errno()) {
printf("Echec de la connexion : %s\n", maxdb_connect_error());
exit();
}
maxdb_report (MAXDB_REPORT_OFF);
$maxdb->query("DROP TABLE mycity");
maxdb_report (MAXDB_REPORT_ERROR);
$maxdb->query("CREATE TABLE mycity LIKE hotel.city");
$maxdb->query("ALTER TABLE mycity ADD id FIXED(11) DEFAULT SERIAL");
$query = "INSERT INTO mycity (zip,name,state) VALUES ('12203','Albany' ,'NY')";
$maxdb->query($query);
printf ("Le nouvel enregistrement a comme identifiant %d.\n", $maxdb->insert_id);
/* Effacement de la table */
$maxdb->query("DROP TABLE mycity");
/* Fermeture de la connexion */
$maxdb->close();
?>
]]>
</programlisting>
</example>
<example>
<title>Style procédural</title>
<programlisting role="php">
<![CDATA[
<?php
$link = maxdb_connect("localhost", "MONA", "RED", "DEMODB");
/* Vérification de la connexion */
if (maxdb_connect_errno()) {
printf("Echec de la connexion : %s\n", maxdb_connect_error());
exit();
}
maxdb_report (MAXDB_REPORT_OFF);
maxdb_query($link,"DROP TABLE mycity");
maxdb_report (MAXDB_REPORT_ERROR);
maxdb_query($link, "CREATE TABLE mycity LIKE hotel.city");
maxdb_query($link, "ALTER TABLE mycity ADD id FIXED(11) DEFAULT SERIAL");
$query = "INSERT INTO mycity (zip,name,state) VALUES ('12203','Albany' ,'NY')";
maxdb_query($link, $query);
printf ("Le nouvel enregistrement a comme identifiant %d.\n", maxdb_insert_id($link));
/* Effacement de la table */
maxdb_query($link, "DROP TABLE mycity");
/* Fermeture de la connexion */
maxdb_close($link);
?>
]]>
</programlisting>
</example>
&example.outputs.similar;
<screen>
<![CDATA[
Le nouvel enregistrement a comme identifiant 1.
]]>
</screen>
</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
-->