HEX
Server: Apache
System: Linux WWW 6.1.0-40-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.153-1 (2025-09-20) x86_64
User: web11 (1011)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: /var/www/dvpis2026/dvpis.kaunokolegija.lt/src/Repository/Poll/PollGroupRepository.php
<?php

namespace App\Repository\Poll;

use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\NonUniqueResultException;
use Doctrine\ORM\NoResultException;

/**
 * PollGroupRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class PollGroupRepository extends EntityRepository
{
    public function findMaxPage()
    {
        try {
            return $this->getEntityManager()
                            ->createQuery(
                                "
                                        SELECT MAX(pg.page) as maxPage 
                                        FROM App:Poll\PollGroup pg
                                    "
                            )
                            ->getSingleScalarResult();
        } catch (NoResultException $e) {
            return null;
        } catch (NonUniqueResultException $e) {
            return null;
        }
    }

    public function findByPage(int $page)
    {
        return $this->getEntityManager()
            ->createQuery("
                SELECT 
                    pg, p, af
                FROM App:Poll\PollGroup pg
                JOIN pg.polls p
                JOIN p.answerFields af
                WHERE pg.page = $page
            ")
            ->getResult()
        ;
    }
}