protected final function loadData($loadReferencedRecords, ARSelectQueryBuilder $query) { $className = get_class($this); $PKCond = null; foreach ($this->schema->getPrimaryKeyList() as $name => $PK) { if ($PK instanceof ARForeignKey) { $PKValue = $this->data[$name]->get()->getID(); } else { $PKValue = $this->data[$name]->get(); } if ($PKCond == null) { $PKCond = new EqualsCond(new ARFieldHandle($className, $name), $PKValue); } else { $PKCond->addAND(new EqualsCond(new ARFieldHandle($className, $name), $PKValue)); } } $query->getFilter()->mergeCondition($PKCond); $rowDataArray = self::fetchDataFromDB($query); if (empty($rowDataArray)) { throw new ARNotFoundException($className, $this->getID()); } if (count($rowDataArray) > 1) { throw new ARException("Unexpected behavior: got more than one record from a database while loading single instance data"); } $parsedRowData = self::prepareDataArray($className, $this->schema, $rowDataArray[0], $loadReferencedRecords); $this->createDataAccessVariables($parsedRowData['recordData'], $this->getID()); if (!empty($parsedRowData['miscData'])) { $this->miscRecordDataHandler($parsedRowData['miscData']); } }
protected function addDateFieldToQuery(ARSelectQueryBuilder $q, $sqlFunction, $alias) { $f = $q->getFilter(); $q->addField(new ARExpressionHandle($sqlFunction), null, $alias); if (self::PIE != $this->chartType) { $f->setGrouping(new ARExpressionHandle($alias)); } $f->setOrder(new ARExpressionHandle($alias)); }