00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
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 ?>