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/AnswerRepository.php
<?php

namespace App\Repository\Poll;

use Doctrine\ORM\EntityRepository;

/**
 * AnswerRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class AnswerRepository extends EntityRepository
{
    public function findByLecturerPage($lecturerId, $page)
    {
        $results = $this->getEntityManager()
                ->createQuery(
                    "SELECT a, af, ar, p, pg
                                    FROM App:Poll\Answer a
                                    JOIN a.answerField af
                                    JOIN a.answerRow ar
                                    JOIN ar.poll p
                                    JOIN p.pollGroup pg
                         WHERE pg.page = $page and ar.lecturer = $lecturerId
                                "
                )
                ->getResult();


        $return = [];
        foreach ($results as $result) {
            $return[$result->getAnswerRow()->getId()][$result->getAnswerField()->getId()] = $result->getName();
        }

        return $return;
    }

    public function deleteAll()
    {
        return $this->getEntityManager()
            ->createQuery(
                "DELETE App:Poll\\Answer t"
            )
            ->execute();
    }
}