Пример #1
0
 /**
  * "Random" find method
  * @param Query $query Query object
  * @param array $options Options
  * @return Query Query object
  */
 public function findRandom(Query $query, array $options)
 {
     $query->order('rand()');
     if (!$query->clause('limit')) {
         $query->limit(1);
     }
     return $query;
 }
Пример #2
0
 /**
  * {@inheritDoc}
  */
 public function scope(Query $query, TokenInterface $token)
 {
     if ($token->negated()) {
         return $query;
     }
     $value = intval($token->value());
     if ($value > 0) {
         $query->limit($value);
     }
     return $query;
 }
 public function findPopular(Query $query, array $options)
 {
     $query->limit(isset($options['limit']) ? $options['limit'] : 10);
     $query->order(['Hashtags.counter' => 'DESC']);
     return $query;
 }
Пример #4
0
 /**
  * Prepare CakePHP paging
  *
  * @param Request $request DataTable request
  */
 protected function preparePaging(Request $request)
 {
     self::$countBeforePaging = $this->query->count();
     $this->query->limit($request->getLength());
     $this->query->offset($request->getStart());
 }