Esempio n. 1
0
 /**
  * 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;
 }
Esempio n. 2
0
 /**
  * Set the default sorting order for the PaginInfo of this table. This will
  * apply only if the order was not yet assigned.
  *
  * @param String $column the column by which to order
  * @param boolean $asc whether the sorting order is ascending or not. Default is false (descending)
  */
 public function setDefaultOrder($column, $asc = true)
 {
     if ($this->pagingInfo->getOrderByColumn() != '') {
         return;
     }
     $this->pagingInfo->setOrderByColumn($column);
     $this->pagingInfo->setOrderByAscending($asc);
 }
Esempio n. 3
0
 /**
  * @covers PagingInfo::getOrderByColumn
  */
 public function testGetOrderByColumn()
 {
     $this->paging->setOrderByColumn("username");
     $this->assertSame("username", $this->paging->getOrderByColumn());
 }