/** * Find out what should be the sort order for the given column if this * column is clicked. * The logic is: If the column is currently the sorting order for this table, * then the sorting order will be the oposite of what it was. * If the column is not the sorting order, the sorting order would be ascending, * unless the argument $descendByDefault is set to true. * * @param String $column the column name * @param boolean $descendByDefault if true, the sorting order will be * descending, unless the column was already the sorting column. * @return String '0' for descending, '1' for ascending. */ private function getNewSortOrderForColumn($column, $descendByDefault) { if ($this->pagingInfo->getOrderByColumn() == $column) { return $this->pagingInfo->isOrderByAscending() ? '0' : '1'; } return $descendByDefault ? '0' : '1'; }
/** * Return the query, with the paging applied to it. * @return String the sql query */ public function getQuery() { if ($this->paging == null) { return $this->sql; } $search = $this->paging->getSearchInfo(); if ($search != null && $this->includeFilter) { $this->applySearchFilter($search); } $newSql = "select SQL_CALC_FOUND_ROWS * from (" . $this->sql . ") _x"; if ($this->paging->getOrderByColumn()) { $newSql .= " order by " . $this->paging->getOrderByColumn(); $newSql .= $this->paging->isOrderByAscending() ? ' asc' : ' desc'; } $newSql .= " limit " . $this->paging->getFirstRecord() . ", " . $this->paging->getRecordsPerPage(); return $newSql; }
/** * @covers PagingInfo::isOrderByAscending */ public function testIsOrderByAscending() { $this->paging->setOrderByAscending(false); $this->assertFalse($this->paging->isOrderByAscending()); }