コード例 #1
0
 /**
  * Creates a new PaginInfo object which sorts by the given column.
  * Records per page is set to a large-enough number.
  * This method can be used when you need a certain finder method to sort
  * by a specific field.
  *
  * @param String $orderByColumn
  * @param Boolean $orderByAscending
  * @return PagingInfo
  */
 public static function newSorter($orderByColumn, $orderByAscending = true)
 {
     $pagingInfo = new PagingInfo();
     $pagingInfo->limit(1000);
     $pagingInfo->setOrderByColumn($orderByColumn);
     $pagingInfo->setOrderByAscending($orderByAscending);
     return $pagingInfo;
 }
コード例 #2
0
 /**
  * @covers QueryPager::getQuery
  * @covers QueryPager::__construct
  */
 public function testGetQueryWithFilter()
 {
     $sql = "SELECT * FROM office";
     $this->paging->setOrderByColumn('officeName');
     $this->paging->setOrderByAscending(false);
     $excepted = "select SQL_CALC_FOUND_ROWS * from (SELECT * FROM office) _x order by officeName desc limit 0, 5";
     $pager = new \QueryPager($sql, $this->paging);
     $this->assertEquals($excepted, $pager->getQuery());
 }
コード例 #3
0
ファイル: Table.php プロジェクト: fruition-sciences/phpfw
 /**
  * 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);
 }
コード例 #4
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;
 }
コード例 #5
0
ファイル: Datatable.php プロジェクト: fruition-sciences/phpfw
 /**
  * Get the actual content published by this datatable.
  * This includes metadata regarding the total number of records, as well as
  * the actual content to be shown on the current page.
  *
  * @return Map - an associative array.
  */
 public function getDocument()
 {
     $doc = array('sEcho' => $this->sEcho, 'iTotalRecords' => $this->totalRecords, 'iTotalDisplayRecords' => $this->pagingInfo->getTotalRows(), 'aaData' => $this->entries);
     return $doc;
 }
コード例 #6
0
 /**
  * @covers PagingInfo::isOrderByAscending
  */
 public function testIsOrderByAscending()
 {
     $this->paging->setOrderByAscending(false);
     $this->assertFalse($this->paging->isOrderByAscending());
 }