Ejemplo n.º 1
0
 protected function query($query, $params = array())
 {
     $result = parent::query($query, $params);
     if (is_a($result, 'Collection')) {
         $library = $this->library;
         $result = $result->map(function ($item) use($library) {
             return $library->item((array) $item);
         });
         return $result;
     } else {
         if (is_a($result, 'Obj')) {
             if (isset($result->aggregation)) {
                 return $result;
             } else {
                 return $this->library->item((array) $result);
             }
         } else {
             return $result;
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Prepare a new query object.
  *
  * @return    \Database\Query
  */
 protected function query()
 {
     $connection = static::resolve();
     $prefix = $connection->prefix();
     $query = new Query($connection, $prefix . $this->table());
     $query->fail()->primaryKeyName($this->primaryKeyName())->fetch(get_class($this));
     return $query;
 }