Example #1
0
 /**
  * Fetch search result
  *
  * @param Model $model
  * @param Where $where
  * @param int   $limit
  * @param int   $offset
  *
  * @return array
  */
 protected function fetchResult(Model $model, Where $where, $limit = 0, $offset = 0)
 {
     $data = array();
     $select = $model->select();
     $select->where($where);
     $select->columns(array_keys($this->meta));
     $select->limit($limit)->offset($offset);
     if ($this->order) {
         $select->order($this->order);
     }
     $rowset = $model->selectWith($select);
     foreach ($rowset as $row) {
         $item = array();
         foreach ($this->meta as $column => $field) {
             $item[$field] = $row[$column];
             if ('content' == $field) {
                 $item[$field] = $this->buildContent($item[$field]);
             }
         }
         $item['url'] = $this->buildUrl($item);
         $data[] = $item;
     }
     return $data;
 }