Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00027 abstract class Sequenceless extends DB
00028 {
00029 protected $sequencePool = array();
00030
00031 abstract protected function getInsertId();
00032
00036 final public function obtainSequence($sequence)
00037 {
00038 $id = Identifier::create();
00039
00040 $this->sequencePool[$sequence][] = $id;
00041
00042 return $id;
00043 }
00044
00045 final public function query(Query $query)
00046 {
00047 $result = $this->queryRaw(
00048 $query->toDialectString($this->getDialect())
00049 );
00050
00051 if (
00052 ($query instanceof InsertQuery)
00053 && !empty($this->sequencePool[$name = $query->getTable().'_id'])
00054 ) {
00055 $id = current($this->sequencePool[$name]);
00056
00057 Assert::isTrue(
00058 $id instanceof Identifier,
00059 'identifier was lost in the way'
00060 );
00061
00062 $id->setId($this->getInsertId())->finalize();
00063
00064 unset(
00065 $this->sequencePool[
00066 $name
00067 ][
00068 key($this->sequencePool[$name])
00069 ]
00070 );
00071 }
00072
00073 return $result;
00074 }
00075 }
00076 ?>