Answer the question
In order to leave comments, you need to log in
Which method to choose in the Phalcon framework to implement the task?
Question:
In the Phalcon framework, I am doing a complex query through phql.
by type:
$phql = 'SELECT ... JOIN ... WHERE ... LIMIT 0, 10';
But there are 100,000 records in the table by WHERE parameters.
So I execute the query like this:
$this->modelsManager->executeQuery($phql);
As a result, 10 lines will be displayed to me.
But I want to know the total number of rows.
If you use: SQL_CALC_FOUND_ROWS - it will throw an error.
If you use classes:
Phalcon\Paginator\Adapter\Model
Phalcon\Paginator\Adapter\QueryBuilder
But they can't get the total number of rows without LIMIT
Here is a piece of code (almost from the documentation):
$builder = $this->modelsManager->createBuilder($phql);
$paginator = new \Phalcon\Paginator\Adapter\QueryBuilder(array(
"builder" => $builder,
"limit"=> 5,
"page" => 1
));
$page = $paginator->getPaginate();
print_r($page->total_pages());
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question