A
A
Alex2015-12-04 12:57:19
PHP
Alex, 2015-12-04 12:57:19

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());

Will output 2, not a large number.
In general, I want to use Phalcon methods, and not make 2 requests or sub-requests.
Does anyone have experience with this kind of thing?
Please do not offer to output everything through PHP and process it, this is a bad option, since this is a highly loaded project.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question