/** * help $this->queryBuilder to construct a PHQL object * apply sort params and return query object * * @param \Phalcon\Mvc\Model\Query\BuilderInterface $query * @return \Phalcon\Mvc\Model\Query\BuilderInterface $query */ public function querySortHelper(\Phalcon\Mvc\Model\Query\BuilderInterface $query) { // process sort $rawSort = $this->searchHelper->getSort('sql'); // detect the correct name space for sort string // notice this might be a fieldname with a sort suffix $fieldBits = explode(':', $rawSort); if (count($fieldBits) > 1) { // isolate just the field name $fieldName = $fieldBits[0]; $suffix = $fieldBits[1]; $preparedSort = $this->prependFieldNameNamespace($fieldName) . '.' . $suffix; } else { $preparedSort = $this->prependFieldNameNamespace($rawSort); } if ($preparedSort != false) { $query->orderBy($preparedSort); } return $query; }
/** * help $this->queryBuilder to construct a PHQL object * apply sort params and return query object * * @param \Phalcon\Mvc\Model\Query\BuilderInterface $query * @return \Phalcon\Mvc\Model\Query\BuilderInterface $query */ public function querySortHelper(\Phalcon\Mvc\Model\Query\BuilderInterface $query) { // process sort $rawSort = $this->searchHelper->getSort('sql'); // by default, use the local namespace $preparedSort = $this->prependFieldNameNamespace($rawSort); if ($preparedSort != false) { $query->orderBy($preparedSort); } return $query; }