https://github.com/phalcon/rest-api
How to deal with Pagination and Searching in this project? Could you please give some examples?
I want to modify the line 137 to below code: https://github.com/phalcon/rest-api/blob/8328c2b6b94284e057bfe571113ae12340e2cd5a/library/Traits/QueryTrait.php#L137
/**
* Runs the builder query if there is no cached data
*
* @param Config $config
* @param Client $cache
* @param Builder $builder
* @param array $where
*
* @return ResultsetInterface
*/
private function getResults(
Config $config,
Client $cache,
Builder $builder,
array $where = []
): ResultsetInterface {
/**
* Calculate the cache key
*/
$phql = $builder->getPhql();
$params = json_encode($where);
$cacheKey = sha1(sprintf('%s-%s.cache', $phql, $params));
if (true !== $config->path('app.devMode') && true === $cache->exists($cacheKey)) {
/** @var ResultsetInterface $data */
$data = $cache->get($cacheKey);
} else {
// use Phalcon\Paginator\Adapter\QueryBuilder;
$paginator = new QueryBuilder(['builder' => $builder, 'limit' => 5, 'page' => 1]);
$data = $paginator->paginate();
//$data = $builder->getQuery()->execute(); <========================== Originally, Line 137
$cache->mset($cacheKey, $data);
}
return $data;
}
It got error:
BaseController::getRecords() must implement interface Phalcon\Mvc\Model\ResultsetInterface, instance of Phalcon\Paginator\Repository returned