00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00020 final class TransactionQueue extends BaseTransaction implements Query
00021 {
00022 private $queue = null;
00023
00024 public function __construct(DB $db)
00025 {
00026 parent::__construct($db);
00027 $this->queue = new Queue();
00028 }
00029
00030 public function getId()
00031 {
00032 return sha1(serialize($this));
00033 }
00034
00035 public function setId($id)
00036 {
00037 throw new UnsupportedMethodException();
00038 }
00039
00043 public function add(Query $query)
00044 {
00045 $this->queue->add($query);
00046
00047 return $this;
00048 }
00049
00054 public function flush()
00055 {
00056 try {
00057 $this->db->queryRaw($this->getBeginString());
00058 $this->queue->flush($this->db);
00059 $this->db->queryRaw("commit;\n");
00060 } catch (DatabaseException $e) {
00061 $this->db->queryRaw("rollback;\n");
00062 throw $e;
00063 }
00064
00065 return $this;
00066 }
00067
00068
00069 public function toDialectString(Dialect $dialect)
00070 {
00071 return $this->queue->toDialectString($dialect);
00072 }
00073
00074 public function toString()
00075 {
00076 return $this->queue->toDialectString(ImaginaryDialect::me());
00077 }
00078 }
00079 ?>