order() public method

Adds order clause, more calls appends to the end.
public order ( $columns, $params ) : self
return self
Example #1
0
      parent::__construct();
      $this->last = $user_prihlasenie->findAll();
  }
  /** Nastavenie poctu poslednych zobrazenych prihlaseni
 * @param type $pocet Pocet poslednych zobrazenych prihlaseni(Min 2)
 */
  public function setPocet($pocet)
  {
Example #2
0
 static function appendSort(Nette\Database\Table\Selection &$query, $sort = NULL)
 {
     if (!is_null($sort)) {
         foreach ($sort as $k => $v) {
             if (Nette\Utils\Validators::isNumericInt($k)) {
                 $query->order($v);
             } else {
                 $query->order($k . ' ' . strtoupper($v));
             }
         }
     }
     return $query;
 }
Example #3
0
 public function order($columns)
 {
     if (!$this->sqlBuilder->getOrder()) {
         // improve index utilization
         $this->sqlBuilder->addOrder("{$this->name}.{$this->column}" . (preg_match('~\\bDESC$~i', $columns) ? ' DESC' : ''));
     }
     return parent::order($columns);
 }
Example #4
0
File: DB.php Project: lohini/cf
 /**
  * Adds ordering to specified column
  *
  * @param string column name
  * @param string one of ordering types
  * @return IDataSource (fluent)
  * @throws \Nette\InvalidArgumentException
  */
 public function sort($column, $order = IDataSource::ASCENDING)
 {
     if (!$this->hasColumn($column)) {
         throw new \Nette\InvalidArgumentException('Trying to sort data source by unknown column.');
     }
     $this->selection->order($this->mapping[$column] . ' ' . ($order === self::ASCENDING ? 'ASC' : 'DESC'));
     return $this;
 }
Example #5
0
 /**
  * Pad:default.
  * @param int         $id
  * @param string|null $order
  * @throws BadRequestException
  */
 public function actionDefault($id, $order)
 {
     $this->loadPad($id);
     $this->notes = $this->noteManager->findByPad($id);
     if ($order) {
         $this->notes->order(OrderHelper::translateParameterToColumns($order));
     }
 }
Example #6
0
 public function order($columns)
 {
     if (!$this->order) {
         // improve index utilization
         $this->order[] = "{$this->delimitedName}.{$this->delimitedColumn}" . (preg_match('~\\bDESC$~i', $columns) ? ' DESC' : '');
     }
     return parent::order($columns);
 }
Example #7
0
 /**
  * API:
  *
  * <code>
  * $this->orderBy('column', EntityCollection::DESC); // ORDER BY [column] DESC
  * // or
  * $this->orderBy(array(
  *	'first'  => EntityCollection::ASC,
  *	'second' => EntityCollection::DESC,
  * ); // ORDER BY [first], [second] DESC
  * </code>
  *
  * @param  string|array $column
  * @param  bool $dir
  * @return EntityCollection
  */
 public function orderBy($column, $dir = NULL)
 {
     if (is_array($column)) {
         foreach ($column as $col => $d) {
             $this->orderBy($col, $d);
         }
     } else {
         $dir === NULL && ($dir = static::ASC);
         $this->selection->order($column . ($dir === static::DESC ? ' DESC' : ''));
     }
     $this->invalidate();
     return $this;
 }
 /**
  * Order data
  * @param  array  $sorting
  * @return self
  */
 public function sort(array $sorting)
 {
     if ($sorting) {
         $this->data_source->getSqlBuilder()->setOrder([], []);
         foreach ($sorting as $column => $sort) {
             $this->data_source->order("{$column} {$sort}");
         }
     } else {
         /**
          * Has the statement already a order by clause?
          */
         if (!$this->data_source->getSqlBuilder()->getOrder()) {
             $this->data_source->order($this->primary_key);
         }
     }
     return $this;
 }
 /**
  * Sort data
  * @param  Sorting $sorting
  * @return static
  */
 public function sort(Sorting $sorting)
 {
     if (is_callable($sorting->getSortCallback())) {
         call_user_func($sorting->getSortCallback(), $this->data_source, $sorting->getSort());
         return $this;
     }
     $sort = $sorting->getSort();
     if (!empty($sort)) {
         $this->data_source->getSqlBuilder()->setOrder([], []);
         foreach ($sort as $column => $order) {
             $this->data_source->order("{$column} {$order}");
         }
     } else {
         /**
          * Has the statement already a order by clause?
          */
         if (!$this->data_source->getSqlBuilder()->getOrder()) {
             $this->data_source->order($this->primary_key);
         }
     }
     return $this;
 }
Example #10
0
 /**
  * @param array $sorting
  */
 public function sort(array $sorting)
 {
     foreach ($sorting as $column => $sort) {
         $this->selection->order("{$column} {$sort}");
     }
 }
Example #11
0
 public function orderBy($row, $sorting = 'ASC')
 {
     return $this->nette_table->order($row . ' ' . $sorting);
 }
Example #12
0
 function order($columns)
 {
     if (!$this->sqlBuilder->getOrder()) {
         $this->sqlBuilder->addOrder("{$this->name}.{$this->column}" . (preg_match('~\\bDESC\\z~i', $columns) ? ' DESC' : ''));
     }
     return parent::order($columns);
 }
 /**
  * @param \Nette\Database\Table\Selection $context
  * @return array
  */
 protected function orderAndFetch(Selection $context)
 {
     return $context->order('section.priority ASC, section.name ASC')->fetchPairs('id', 'name');
 }
 /**
  * Adds order clause, more calls appends to the end.
  * @param string $columns
  * @return self
  */
 public function order($columns)
 {
     $this->selection->order($columns);
     return $this;
 }
Example #15
0
 function order($columns)
 {
     if (!$this->order) {
         $this->order[] = "{$this->delimitedName}.{$this->delimitedColumn}" . (preg_match('~\\bDESC$~i', $columns) ? ' DESC' : '');
     }
     return parent::order($columns);
 }
Example #16
0
 public function orderBy($row, $sorting = 'ASC')
 {
     return $this->netteTable->order($this->prefixColumn($row) . ' ' . $sorting);
 }
Example #17
0
 /**
  * Order data
  * @param string $by
  * @param bool $invert
  * @throws \Nette\InvalidArgumentException
  */
 public function order($by, $invert)
 {
     $this->table->order($by . ' ' . ($invert ? 'DESC' : 'ASC'));
 }
 /**
  * @param Selection $context
  * @param string $via [optional]
  * @return Selection
  */
 public function order(Selection $context, $via = '')
 {
     $viaParam = $via ? "{$via}." : '';
     return $context->order("{$viaParam}priority ASC, {$viaParam}name ASC");
 }
 /**
  * @param \Nette\Database\Table\Selection $context
  * @param string $via [optional]
  * @return \Nette\Database\Table\Selection
  */
 public function order(\Nette\Database\Table\Selection $context, $via = '')
 {
     $viaParam = $via ? "{$via}." : '';
     return $context->order("{$viaParam}priority ASC, {$viaParam}name ASC");
 }