/** * Add an order by raw expression for this query * * @param string $expression Raw expression to sort. * @param string $direction Values ASC or DESC. * * @return SugarQuery */ public function orderByRaw($expression, $direction = 'DESC') { $orderBy = new SugarQuery_Builder_Orderby($this, $direction); $orderBy->addRaw($expression); $this->order_by[] = $orderBy; return $this; }
/** * Add additional column to `ORDER BY` clause for order stability, defaults * to using the `id` column. * * @param SugarQuery_Builder_Orderby[] $orderBy List of already existing `ORDER BY` defs * @param string $column Unique column to add, defaults to `id` * @return SugarQuery_Builder_Orderby[] */ protected function applyOrderByStability(array $orderBy, $column = 'id') { $uniqueCol = new SugarQuery_Builder_Orderby($this->sugar_query); $uniqueCol->addField($column); $orderBy[] = $uniqueCol; return $orderBy; }