예제 #1
0
파일: table.php 프로젝트: stonyyi/anahita
 /**
  * Builds LIMIT clause for the query
  */
 protected function _buildQueryLimit(KDatabaseQuery $query)
 {
     $limit = $this->_state->limit;
     if ($limit) {
         $offset = $this->_state->offset;
         $total = $this->getTotal();
         //If the offset is higher than the total recalculate the offset
         if ($offset !== 0 && $total !== 0) {
             if ($offset >= $total) {
                 $offset = floor(($total - 1) / $limit) * $limit;
                 $this->_state->offset = $offset;
             }
         }
         $query->limit($limit, $offset);
     }
 }