public function sort(array $sorting)
 {
     $this->statement->removeClause('ORDER BY');
     list($column, $sort) = $sorting;
     $column = sprintf('[%s]', $column);
     $this->statement->orderBy($column, $sort);
 }
Example #2
0
 public function getData()
 {
     if ($this->filterState) {
         $this->filter($this->filterState);
     }
     if ($this->sortState) {
         $this->sort($this->sortState);
     }
     return $this->dataSource->fetchAll();
 }
Example #3
0
 /**
  * @param  DibiConnection
  */
 public function __construct(DibiConnection $connection)
 {
     $this->connection = $connection;
     if (self::$normalizer === NULL) {
         self::$normalizer = new DibiHashMap(array(__CLASS__, '_formatClause'));
     }
 }
Example #4
0
 /**
  * @param  Connection
  */
 public function __construct(Connection $connection)
 {
     $this->connection = $connection;
     if (self::$normalizer === NULL) {
         self::$normalizer = new HashMap([__CLASS__, '_formatClause']);
     }
 }
Example #5
0
 /**
  * Constructs fluent object
  *
  * @param string $rowClass row class
  * @param Nette\DI\Container DI
  */
 public function __construct($rowClass, Nette\DI\Container $context)
 {
     $this->rowClass = $rowClass;
     $this->context = $context;
     parent::__construct($this->context->getByType('DibiConnection'));
 }
Example #6
0
 /**
  * @param array $sorting
  */
 public function sort(array $sorting)
 {
     foreach ($sorting as $column => $sort) {
         $this->fluent->orderBy("%n", $column, $sort);
     }
 }
Example #7
0
 private function addSearchCondition(DibiFluent $sql, SearchRequest $request)
 {
     if ($request->query == "" && $request->from == "") {
         // limit results to topics
         $sql->where("data.parent_id = 0");
     } else {
         if ($request->query != "") {
             $sql->where("MATCH(data.message) AGAINST (%s IN BOOLEAN MODE)", $request->query);
         }
         if ($request->from != "") {
             $sql = $sql->where("data.from_name LIKE %~like~", $request->from);
             // protection of hidden names in closed/secret groups
             $sql = $sql->where("groups.closed = 0");
         }
     }
     if (count($request->tags)) {
         $taggedPostsId = $this->getMatchedIdByTags($request->tags);
         $sql = $sql->where("data.id IN %in", $taggedPostsId);
     }
     if (count($request->groups)) {
         $sql->where("data.group_id IN %in", $request->groups);
     }
 }
Example #8
0
 public function setFilter(array $filter)
 {
     if ($filter) {
         $this->fluent->where("%and", $this->convertFilter($filter));
     }
 }
Example #9
0
 /**
  * Vytvoří z DibiFluent pole entit.
  * @param \DibiFluent $datasource
  * @param int|null $limit
  * @param int|null $offset
  * @return IEntity[]
  */
 public function createEntities(\DibiFluent $datasource, $limit = NULL, $offset = NULL)
 {
     $entities = array();
     foreach ($datasource->fetchAll($offset, $limit) as $row) {
         $entities[] = $this->createEntity($row);
     }
     return $entities;
 }
Example #10
0
 public function appendTo(DibiFluent $query)
 {
     return $query->groupBy($this->column->getEscaped());
 }