Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00017 abstract class UnifiedContainerWorker
00018 {
00019 protected $criteria = null;
00020 protected $container = null;
00021
00022 abstract public function makeFetchQuery();
00023 abstract public function sync($insert, $update = array(), $delete);
00024
00025 public function __construct(UnifiedContainer $uc)
00026 {
00027 $this->container = $uc;
00028 }
00029
00033 public function setCriteria(Criteria $criteria)
00034 {
00035 $this->criteria = $criteria;
00036
00037 return $this;
00038 }
00039
00043 public function getCriteria()
00044 {
00045 return $this->criteria;
00046 }
00047
00051 public function makeCountQuery()
00052 {
00053 $query = $this->makeFetchQuery();
00054
00055 if ($query->isDistinct()) {
00056 $countFunction =
00057 SQLFunction::create(
00058 'count',
00059 DBField::create(
00060 $this->container->getDao()->getIdName(),
00061 $this->container->getDao()->getTable()
00062 )
00063 )->
00064 setAggregateDistinct();
00065
00066 $query->unDistinct();
00067
00068 } else {
00069 $countFunction = SQLFunction::create('count', DBValue::create('*'));
00070 }
00071
00072 return $query->
00073 dropFields()->
00074 dropOrder()->
00075 dropLimit()->
00076 get(
00077 $countFunction->setAlias('count')
00078 );
00079 }
00080
00081 public function dropList()
00082 {
00083 $dao = $this->container->getDao();
00084
00085 DBPool::getByDao($dao)->queryNull(
00086 OSQL::delete()->from($this->container->getHelperTable())->
00087 where(
00088 Expression::eq(
00089 $this->container->getParentIdField(),
00090 $this->container->getParentObject()->getId()
00091 )
00092 )
00093 );
00094
00095 $dao->uncacheLists();
00096
00097 return $this;
00098 }
00099
00103 protected function makeSelectQuery()
00104 {
00105 if ($this->criteria)
00106 return $this->criteria->toSelectQuery();
00107
00108 return $this->container->getDao()->makeSelectHead();
00109 }
00110 }
00111 ?>