From 26406f61f07f9087527c5431045f31e6329cdd24 Mon Sep 17 00:00:00 2001 From: zYne Date: Wed, 10 Jan 2007 21:16:27 +0000 Subject: [PATCH] docs for sequence handling --- ...tarted - Record identifiers - Sequence.php | 68 +++++++++++++++++++ ...rted - Record identifiers - Sequential.php | 0 manual/documentation.php | 9 ++- 3 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 manual/docs/Getting started - Record identifiers - Sequence.php delete mode 100644 manual/docs/Getting started - Record identifiers - Sequential.php diff --git a/manual/docs/Getting started - Record identifiers - Sequence.php b/manual/docs/Getting started - Record identifiers - Sequence.php new file mode 100644 index 000000000..9235c9532 --- /dev/null +++ b/manual/docs/Getting started - Record identifiers - Sequence.php @@ -0,0 +1,68 @@ + +Doctrine supports sequences for generating record identifiers. 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 AUTO_INCREMENT. +

+Doctrine knows how to do sequence generation in the background so you don't have to worry about calling database specific queries - Doctrine does it for you, all you need to do +is define a column as a sequence column and optionally provide the name of the sequence table and the id column name of the sequence table. +

+Consider the following record definition: +

+hasColumn('id', 'integer', null, array('primary', 'sequence')); + \$this->hasColumn('name', 'string'); + } +} +?>"); +?> +

+By default Doctrine uses the following format for sequence tables [tablename]_seq. If you wish to change this you can use the following +piece of code to change the formatting: +

+setAttribute(Doctrine::ATTR_SEQNAME_FORMAT, +'%s_my_seq'); +?>"); +?> +

+Doctrine uses column named id as the sequence generator column of the sequence table. If you wish to change this globally (for all connections and all tables) +you can use the following code: +

+setAttribute(Doctrine::ATTR_SEQCOL_NAME, +'my_seq_column'); +?>"); +?> +

+In the following example we do not wish to change global configuration we just want to make the id column to use sequence table called +book_sequence. It can be done as follows:

+hasColumn('id', 'integer', null, array('primary', 'sequence' => 'book_sequence')); + \$this->hasColumn('name', 'string'); + } +} +?>"); +?> +

+Here we take the preceding example a little further: we want to have a custom sequence column. Here it goes:

+hasColumn('id', 'integer', null, array('primary', 'sequence' => array('book_sequence', 'sequence'))); + \$this->hasColumn('name', 'string'); + } +} +?>"); +?> diff --git a/manual/docs/Getting started - Record identifiers - Sequential.php b/manual/docs/Getting started - Record identifiers - Sequential.php deleted file mode 100644 index e69de29bb..000000000 diff --git a/manual/documentation.php b/manual/documentation.php index f3a7db081..814bc8252 100644 --- a/manual/documentation.php +++ b/manual/documentation.php @@ -113,7 +113,7 @@ $menu = array('Getting started' => 'Autoincremented', 'Natural', 'Composite', - 'Sequential') + 'Sequence') ), 'Connection management' => array( @@ -326,7 +326,12 @@ $menu = array('Getting started' => 'Examples', 'Planned', 'Technical Details', - 'Maintainer'), + 'Maintainer'), + 'Db_Profiler' => array( + 'Introduction', + 'Basic usage', + 'Advanced usage', + ), 'Hook' => array( 'Introduction', 'Building queries',