Skip to content

I set the initial value of the First Result in query Builder. Why didn't I add Pagerfanta into the Offset when using Pagerfanta #263

@tb07

Description

@tb07
public function getAuthorProducts($uuid)
{
    $queryBuilder = $this->createQueryBuilder('o')
        ->addSelect('author')
        ->innerJoin('o.author', 'author')
        ->andWhere("author.uuid=:uuid")
        ->andWhere("o.enabled=:enabled")
        ->andWhere("o.isShow=:isShow")
        ->setParameter("isShow", true)
        ->setParameter("enabled", true)
        ->setParameter("uuid", $uuid)
        ->setFirstResult(5)
    ;

    return $this->getPaginator($queryBuilder);
}

I print the Paginator
image

Query Builder has FirstResult in it

But FirstResult didn't work in the end

I notice that "Pagerfanta/Pagerfanta, "line 316 is not going to fetch the initial FirstResult

private function getCurrentPageResultsFromAdapter()
{
    $offset = $this->calculateOffsetForCurrentPageResults();
    $length = $this->getMaxPerPage();

    return $this->adapter->getSlice($offset, $length);
}

private function calculateOffsetForCurrentPageResults()
{
    return ($this->getCurrentPage() - 1) * $this->getMaxPerPage();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions