BaseTransaction.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 
00017     abstract class BaseTransaction
00018     {
00019         protected $db       = null;
00020         
00021         protected $isoLevel = null;
00022         protected $mode     = null;
00023         
00024         abstract public function flush();
00025         
00026         public function __construct(DB $db)
00027         {
00028             $this->db = $db;
00029         }
00030         
00034         public function setDB(DB $db)
00035         {
00036             $this->db = $db;
00037             
00038             return $this;
00039         }
00040         
00044         public function getDB()
00045         {
00046             return $this->db;
00047         }
00048         
00052         public function setIsolationLevel(IsolationLevel $level)
00053         {
00054             $this->isoLevel = $level;
00055             
00056             return $this;
00057         }
00058         
00062         public function setAccessMode(AccessMode $mode)
00063         {
00064             $this->mode = $mode;
00065             
00066             return $this;
00067         }
00068         
00069         protected function getBeginString()
00070         {
00071             $begin = 'start transaction';
00072             
00073             if ($this->isoLevel)
00074                 $begin .= ' '.$this->isoLevel->toString();
00075             
00076             if ($this->mode)
00077                 $begin .= ' '.$this->mode->toString();
00078             
00079             return $begin.";\n";
00080         }
00081     }
00082 ?>