UnifiedContainerWorker.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: UnifiedContainerWorker.class.php 4687 2007-12-09 18:57:18Z voxus $ */
00012 
00018     abstract class UnifiedContainerWorker
00019     {
00020         protected $criteria     = null;
00021         protected $oq           = null;
00022         protected $container    = null;
00023         
00024         abstract public function makeFetchQuery();
00025         abstract public function sync(&$insert, &$update = array(), &$delete);
00026         
00027         public function __construct(UnifiedContainer $uc)
00028         {
00029             $this->container = $uc;
00030         }
00031         
00035         public function setObjectQuery(ObjectQuery $oq)
00036         {
00037             $this->oq = $oq;
00038             
00039             return $this;
00040         }
00041         
00045         public function setCriteria(Criteria $criteria)
00046         {
00047             $this->criteria = $criteria;
00048             
00049             return $this;
00050         }
00051         
00055         public function getCriteria()
00056         {
00057             return $this->criteria;
00058         }
00059         
00063         public function makeCountQuery()
00064         {
00065             return
00066                 $this->
00067                     makeFetchQuery()->
00068                     dropFields()->
00069                     dropOrder()->
00070                     get(
00071                         SQLFunction::create('count', '*')->setAlias('count')
00072                     );
00073         }
00074         
00078         protected function makeSelectQuery()
00079         {
00080             if ($this->criteria)
00081                 return $this->criteria->toSelectQuery();
00082             elseif ($this->oq)
00083                 return $this->oq->toSelectQuery($this->container->getDao());
00084             
00085             return $this->container->getDao()->makeSelectHead();
00086         }
00087     }
00088 ?>

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