コード例 #1
0
 /**
  * @covers PagingInfo::getFirstRecord
  */
 public function testGetFirstRecord()
 {
     $pageNumber = 10;
     $recordPerPage = 5;
     $res = 50;
     $this->paging->setPageNumber($pageNumber);
     $this->paging->setRecordsPerPage($recordPerPage);
     $this->assertEquals($res, $this->paging->getFirstRecord());
 }
コード例 #2
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;
 }