limit() public method

Restrict the query to a subset of the results.
public limit ( integer $limit, integer $offset = null )
$limit integer Number of items to fetch.
$offset integer Offset to start fetching at.
示例#1
0
文件: Rdo.php 项目: raz0rsdge/horde
 /**
  * get any number of pastes from a bin, ordered by date, narrowed by limit and offset
  * @param string  $bin  A paste bin to query
  * @param integer $limit  a maximum of pastes to retrieve (optional, default to null = all)
  * @param integer start  a number of pastes to skip before retrieving (optional, default to null = begin with first)
  * @return array  a list of pastes
  */
 public function getPastes($bin, $limit = null, $start = null)
 {
     $pm = $this->_mappers->create('Pastie_Entity_PasteMapper');
     $query = new Horde_Rdo_Query($pm);
     $query->sortBy('paste_timestamp DESC');
     if ($limit !== null) {
         if ($start === null) {
             $start = 0;
         }
         $query->limit($limit, $start);
     }
     $pastes = array();
     foreach ($pm->find($query) as $paste) {
         $pastes[$paste['paste_uuid']] = $this->_fromBackend($paste);
     }
     return $pastes;
 }