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()); }
/** * @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; }
/** * @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; }