Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 26 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| SolvEventRepository | |
0.00% |
0 / 26 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
| getSolvEventsForYear | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
2 | |||
| setResultForSolvEvent | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
2 | |||
| deleteBySolvUid | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Olz\Repository; |
| 4 | |
| 5 | use Olz\Entity\SolvEvent; |
| 6 | use Olz\Repository\Common\OlzRepository; |
| 7 | |
| 8 | /** |
| 9 | * @extends OlzRepository<SolvEvent> |
| 10 | */ |
| 11 | class SolvEventRepository extends OlzRepository { |
| 12 | protected string $entityClass = SolvEvent::class; |
| 13 | |
| 14 | /** @return array<SolvEvent> */ |
| 15 | public function getSolvEventsForYear(int $year): array { |
| 16 | $sane_year = intval($year); |
| 17 | $sane_next_year = $sane_year + 1; |
| 18 | $dql = " |
| 19 | SELECT se |
| 20 | FROM {$this->entityClass} se |
| 21 | WHERE |
| 22 | se.date >= '{$sane_year}-01-01' |
| 23 | AND se.date < '{$sane_next_year}-01-01' |
| 24 | "; |
| 25 | $query = $this->getEntityManager()->createQuery($dql); |
| 26 | return $query->getResult(); |
| 27 | } |
| 28 | |
| 29 | public function setResultForSolvEvent(int $solv_uid, string $rank_link): mixed { |
| 30 | $db = $this->dbUtils()->getDb(); |
| 31 | |
| 32 | $sane_solv_uid = intval($solv_uid); |
| 33 | $sane_rank_link = $db->escape_string($rank_link); |
| 34 | $dql = " |
| 35 | UPDATE {$this->entityClass} se |
| 36 | SET se.rank_link = '{$sane_rank_link}' |
| 37 | WHERE se.solv_uid = '{$sane_solv_uid}' |
| 38 | "; |
| 39 | $query = $this->getEntityManager()->createQuery($dql); |
| 40 | return $query->execute(); |
| 41 | } |
| 42 | |
| 43 | public function deleteBySolvUid(int $solv_uid): mixed { |
| 44 | $sane_solv_uid = intval($solv_uid); |
| 45 | $dql = " |
| 46 | DELETE {$this->entityClass} se |
| 47 | WHERE se.solv_uid = '{$sane_solv_uid}' |
| 48 | "; |
| 49 | $query = $this->getEntityManager()->createQuery($dql); |
| 50 | return $query->execute(); |
| 51 | } |
| 52 | } |