cvs: peardoc /en/package/database/db intro-sequences.xml

From: Date: Thu, 05 Feb 2004 05:05:49 +0000
Subject: cvs: peardoc /en/package/database/db intro-sequences.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-2419@lists.php.net to get a copy of this message
danielc Thu Feb 5 00:05:49 2004 EDT Modified files: /peardoc/en/package/database/db intro-sequences.xml Log: Document how backend names are created. Clean up example. Break up text a bit. http://cvs.php.net/diff.php/peardoc/en/package/database/db/intro-sequences.xml?r1=1.8&r2=1.9&ty=u Index: peardoc/en/package/database/db/intro-sequences.xml diff -u peardoc/en/package/database/db/intro-sequences.xml:1.8 peardoc/en/package/database/db/intro-sequences.xml:1.9 --- peardoc/en/package/database/db/intro-sequences.xml:1.8 Tue Jan 27 02:20:58 2004 +++ peardoc/en/package/database/db/intro-sequences.xml Thu Feb 5 00:05:48 2004 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.8 $ --> +<!-- $Revision: 1.9 $ --> <refentry id="package.database.db.intro-sequences"> <refnamediv> <refname>Introduction - Sequences</refname> @@ -10,6 +10,8 @@ Sequences are a way of offering unique IDs for data rows. If you do most of your work with e.g. MySQL, think of sequences as another way of doing <constant>AUTO_INCREMENT</constant>. + </para> + <para> It's quite simple, first you request an ID, and then you insert that value in the ID field of the new row you're creating. You can have more than one sequence @@ -22,17 +24,52 @@ <title>Using a sequence</title> <programlisting role="php"> <![CDATA[ -... +<?php +// Once you have a valid DB object named $db... $id = $db->nextId('mySequence'); + // Use the ID in your INSERT query $res = $db->query("INSERT INTO myTable (id,text) VALUES ($id,'foo')"); -... +?> ]]> </programlisting> </example> </para> </refsect1> + <refsect1 id="package.database.db.intro-sequences.note"> + &title.note; + <para> + If you need to manually access the database objects PEAR DB uses + to store sequence information, take note that the backend objects + are named by passing the <parameter>$seq_name</parameter> argument + you provide to PEAR DB's sequence methods through PHP's + <function>sprintf</function> function using the value from the + <varname>seqname_format</varname> option as the + <function>sprintf</function> format argument. + </para> + <para> + The default <varname>seqname_format</varname> is + <literal>%s_seq</literal> and it can be chaned when + <link linkend="package.database.db.db.connect"> + <function>connect</function></link>'ing or via + <link linkend="package.database.db.db-common.setoption"> + <function>setOption</function></link>. + </para> + </refsect1> + + <refsect1 id="package.database.db.intro-sequences.see"> + &title.see; + <para> + <link linkend="package.database.db.db-common.createsequence"> + <function>createSequence</function></link>, + <link linkend="package.database.db.db-common.nextid"> + <function>nextId</function></link>, + <link linkend="package.database.db.db-common.dropsequence"> + <function>dropSequence</function></link> + </para> + </refsect1> + </refentry> <!-- Keep this comment at the end of the file Local variables: @@ -53,4 +90,3 @@ vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> -

« previous php.pear.doc (#2419) next »