1 |
<?php
|
2 |
/*
|
3 |
* $Id: Sequence.php 2963 2007-10-21 06:23:59Z Jonathan.Wage $
|
4 |
*
|
5 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
6 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
7 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
8 |
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
9 |
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
10 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
11 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
12 |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
13 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
14 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
15 |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
16 |
*
|
17 |
* This software consists of voluntary contributions made by many individuals
|
18 |
* and is licensed under the LGPL. For more information, see
|
19 |
* <http://www.phpdoctrine.org>.
|
20 |
*/
|
21 |
Doctrine::autoload('Doctrine_Connection_Module');
|
22 |
/**
|
23 |
* Doctrine_Sequence
|
24 |
* The base class for sequence handling drivers.
|
25 |
*
|
26 |
* @package Doctrine
|
27 |
* @subpackage Sequence
|
28 |
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
29 |
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
30 |
* @link www.phpdoctrine.org
|
31 |
* @since 1.0
|
32 |
* @version $Revision: 2963 $
|
33 |
*/
|
34 |
class Doctrine_Sequence extends Doctrine_Connection_Module
|
35 |
{
|
36 |
/**
|
37 |
* Returns the next free id of a sequence
|
38 |
*
|
39 |
* @param string $seqName name of the sequence
|
40 |
* @param bool when true missing sequences are automatic created
|
41 |
*
|
42 |
* @return integer next id in the given sequence
|
43 |
*/
|
44 |
public function nextId($seqName, $ondemand = true)
|
45 |
{
|
46 |
throw new Doctrine_Sequence_Exception('method not implemented');
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
* Returns the autoincrement ID if supported or $id or fetches the current
|
51 |
* ID in a sequence called: $table.(empty($field) ? '' : '_'.$field)
|
52 |
*
|
53 |
* @param string name of the table into which a new row was inserted
|
54 |
* @param string name of the field into which a new row was inserted
|
55 |
*/
|
56 |
public function lastInsertId($table = null, $field = null)
|
57 |
{
|
58 |
throw new Doctrine_Sequence_Exception('method not implemented');
|
59 |
}
|
60 |
|
61 |
/**
|
62 |
* Returns the current id of a sequence
|
63 |
*
|
64 |
* @param string $seqName name of the sequence
|
65 |
*
|
66 |
* @return integer current id in the given sequence
|
67 |
*/
|
68 |
public function currId($seqName)
|
69 |
{
|
70 |
$this->warnings[] = 'database does not support getting current
|
71 |
sequence value, the sequence value was incremented';
|
72 |
return $this->nextId($seqName);
|
73 |
}
|
74 |
} |