コード例 #1
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());
 }
コード例 #2
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;
 }
コード例 #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
ファイル: Datatable.php プロジェクト: fruition-sciences/phpfw
 /**
  * Setup order-by info (to be kept in the 'pagingInfo' object), based on
  * parameters that may exist in the request, or using default values.
  *
  * @param Context $ctx
  */
 private function initOrderingInfo($ctx)
 {
     if ($ctx->getRequest()->containsKey('iSortCol_0')) {
         $sortColumnIndex = $ctx->getRequest()->getLong('iSortCol_0');
         $sortOrder = $ctx->getRequest()->getString('sSortDir_0', 'asc');
         $this->pagingInfo->setOrderByColumn($this->aColumns[$sortColumnIndex]);
         $this->pagingInfo->setOrderByAscending($sortOrder == 'asc');
     }
 }
コード例 #5
0
 /**
  * @covers PagingInfo::isOrderByAscending
  */
 public function testIsOrderByAscending()
 {
     $this->paging->setOrderByAscending(false);
     $this->assertFalse($this->paging->isOrderByAscending());
 }