/** * "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; }
/** * {@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; }
/** * 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()); }