Skip to content

Is it possible GetCurrent Page Results() returned an array of DTO objects ? #48

Description

@nickicool

In DBAL 3 will dropped support fetching objects with custom class like:

$stmt->setFetchMode(FetchMode::CUSTOM_OBJECT, ArticleDTO::class);

Therefore, now in the array $articles there will be a regular associative array, instead of `ArticleDTO[]'. Is it possible to substitute the output of the getCurrentPageResults() method?

function getArticles()
{
    $queryBuilder = $connection->createQueryBuilder();
    $queryBuilder
        ->select('id, title, content, authorName')
        ->from('articles');

    $countQueryBuilderModifier = static function (QueryBuilder $queryBuilder): void {
        $queryBuilder->select('COUNT(DISTINCT id) AS total_results')
            ->setMaxResults(1);
    };

    $paginator = new Pagerfanta(new QueryAdapter($queryBuilder, $countQueryBuilderModifier));
    $paginator->setMaxPerPage(10);
    $paginator->setCurrentPage(1);

    return $paginator;
}

$paginator = getArticles();
$articles = $paginator->getCurrentPageResults();

Or maybe there is another solution so that GetCurrentPageResults() returns an array of ArticleDTO objects?

Activity

  1. locked and limited conversation to collaborators on Jun 9, 2022
  2. converted this issue into a discussion #49 on Jun 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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