TransactionQueue.class.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************************
00003  *   Copyright (C) 2005-2007 by Konstantin V. Arkhipov                     *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Lesser General Public License as        *
00007  *   published by the Free Software Foundation; either version 3 of the    *
00008  *   License, or (at your option) any later version.                       *
00009  *                                                                         *
00010  ***************************************************************************/
00011 /* $Id: TransactionQueue.class.php 4687 2007-12-09 18:57:18Z voxus $ */
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         // to satisfy Query interface
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 ?>

Generated on Sun Dec 9 21:56:23 2007 for onPHP by  doxygen 1.5.4