Exemplo n.º 1
0
 protected function setOrderAndSegmentation()
 {
     $this->setExternalSorting(true);
     $this->setExternalSegmentation(true);
     if (!$this->getDefaultOrderField()) {
         $this->setDefaultOrderField($this->active_record_list->getAR()->getArFieldList()->getPrimaryField()->getName());
     }
     $this->determineLimit();
     $this->determineOffsetAndOrder();
     $this->setMaxCount($this->active_record_list->count());
     $this->active_record_list->orderBy($this->getOrderField(), $this->getOrderDirection());
     $this->active_record_list->limit($this->getOffset(), $this->getLimit());
 }
Exemplo n.º 2
0
 /**
  * @param ActiveRecordList $arl
  *
  * @return mixed|string
  */
 protected function buildQuery(ActiveRecordList $arl)
 {
     // SELECTS
     $q = $arl->getArSelectCollection()->asSQLStatement();
     // Concats
     $q .= $arl->getArConcatCollection()->asSQLStatement();
     $q .= ' FROM ' . $arl->getAR()->getConnectorContainerName();
     // JOINS
     $q .= $arl->getArJoinCollection()->asSQLStatement();
     // WHERE
     $q .= $arl->getArWhereCollection()->asSQLStatement();
     // ORDER
     $q .= $arl->getArOrderCollection()->asSQLStatement();
     // LIMIT
     $q .= $arl->getArLimitCollection()->asSQLStatement();
     //TODO: using template in the model.
     if ($arl->getDebug()) {
         global $tpl;
         if ($tpl instanceof ilTemplate) {
             ilUtil::sendInfo($q);
         } else {
             var_dump($q);
             // FSX
         }
     }
     $arl->setLastQuery($q);
     return $q;
 }
Exemplo n.º 3
0
 /**
  * @param null $key
  * @param null $values
  *
  * @return array
  */
 public static function getArray($key = NULL, $values = NULL)
 {
     $srModelObjectList = new ActiveRecordList(self::getCalledClass());
     return $srModelObjectList->getArray($key, $values);
 }
Exemplo n.º 4
0
 /**
  * @param ActiveRecordList $arl
  *
  * @internal param $q
  *
  * @return array
  */
 public function readSet(ActiveRecordList $arl)
 {
     $session = self::getSessionForActiveRecord($arl->getAR());
     foreach ($session as $i => $s) {
         $session[$i] = (array) $s;
     }
     foreach ($arl->getArWhereCollection()->getWheres() as $w) {
         $fieldname = $w->getFieldname();
         $v = $w->getValue();
         $operator = $w->getOperator();
         foreach ($session as $i => $s) {
             $session[$i] = (array) $s;
             switch ($operator) {
                 case '=':
                     if ($s[$fieldname] != $v) {
                         unset($session[$i]);
                     }
                     break;
             }
         }
     }
     return $session;
 }
Exemplo n.º 5
0
 /**
  * @param string $last_query
  */
 public static function setLastQuery($last_query)
 {
     self::$last_query = $last_query;
 }
Exemplo n.º 6
0
 public function __construct()
 {
     parent::__construct(new arMessage());
 }