Skip to content

Commit

Permalink
Replace fetchAll with fetchAllAssociative
Browse files Browse the repository at this point in the history
  • Loading branch information
LucWollants committed Jan 5, 2024
1 parent 082af95 commit b09c021
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 20 deletions.
5 changes: 2 additions & 3 deletions app/Console/Command/ExcludeInvalidLabels.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use CultuurNet\UDB3\Model\ValueObject\Identity\UUID;
use CultuurNet\UDB3\Model\ValueObject\Taxonomy\Label\LabelName;
use Doctrine\DBAL\Connection;
use PDO;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down Expand Up @@ -77,7 +76,7 @@ private function getAllLabelsCount(): int
->where('excluded = :excluded')
->setParameter(':excluded', 0)
->execute()
->fetchAll()
->fetchAllAssociative()
);
}

Expand All @@ -91,6 +90,6 @@ private function getLabelsFromFirstResult(int $firstResult): array
->setFirstResult($firstResult)
->setMaxResults(self::MAX_RESULTS)
->execute()
->fetchAll(PDO::FETCH_ASSOC);
->fetchAllAssociative();
}
}
2 changes: 1 addition & 1 deletion app/Console/Command/FindOutOfSyncProjections.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
->setParameter(':last_id', $input->getArgument('last-id'))
->groupBy('uuid')
->execute()
->fetchAll();
->fetchAllAssociative();

foreach ($results as $result) {
$uuid = $result['uuid'];
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Command/ReplaceNewsArticlePublisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private function getNewsArticleCount(string $publisher): int
->where('publisher = :publisher')
->setParameter(':publisher', $publisher)
->execute()
->fetchAll()
->fetchAllAssociative()
);
}

Expand Down
5 changes: 2 additions & 3 deletions app/Console/Command/UpdateUniqueLabels.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use PDO;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;
use Symfony\Component\Console\Command\Command;
Expand Down Expand Up @@ -101,7 +100,7 @@ private function getAllLabelAddedEvents(int $offset): array
->setFirstResult($offset)
->setMaxResults(self::MAX_RESULTS)
->execute()
->fetchAll(PDO::FETCH_ASSOC);
->fetchAllAssociative();
}

private function getAllLabelAddedEventsCount(): int
Expand All @@ -113,7 +112,7 @@ private function getAllLabelAddedEventsCount(): int
->where('type = "' . self::LABEL_CREATED . '"')
->orderBy('id')
->execute()
->fetchAll()
->fetchAllAssociative()
);
}

Expand Down
4 changes: 2 additions & 2 deletions app/Console/Command/UpdateUniqueOrganizers.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private function getAllOrganizerEvents(int $offset): array
->setFirstResult($offset)
->setMaxResults(self::MAX_RESULTS)
->execute()
->fetchAll(PDO::FETCH_ASSOC);
->fetchAllAssociative();
}

private function getAllOrganizerEventsCount(): int
Expand All @@ -127,7 +127,7 @@ private function getAllOrganizerEventsCount(): int
->orWhere('type = "' . self::ORGANIZER_WEBSITE_UPDATED . '"')
->orderBy('id')
->execute()
->fetchAll()
->fetchAllAssociative()
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Contributor/DbalContributorRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function isContributor(UUID $id, EmailAddress $emailAddress): bool
->setParameter(':id', $id->toString())
->setParameter(':email', $emailAddress->toString())
->execute()
->fetchAll();
->fetchAllAssociative();

return count($results) > 0;
}
Expand Down
5 changes: 2 additions & 3 deletions src/Curators/DBALNewsArticleRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use CultuurNet\UDB3\Model\ValueObject\Translation\Language;
use CultuurNet\UDB3\Model\ValueObject\Web\Url;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\FetchMode;

final class DBALNewsArticleRepository implements NewsArticleRepository
{
Expand All @@ -30,7 +29,7 @@ public function getById(UUID $id): NewsArticle
->where('id = :id')
->setParameter(':id', $id->toString())
->execute()
->fetchAll(FetchMode::ASSOCIATIVE);
->fetchAllAssociative();

if (count($newsArticleRows) !== 1) {
throw new NewsArticleNotFound($id);
Expand Down Expand Up @@ -74,7 +73,7 @@ public function search(NewsArticleSearch $newsArticleSearch): NewsArticles
$newsArticleRows = $query
->setMaxResults($newsArticleSearch->getItemsPerPage())
->execute()
->fetchAll(FetchMode::ASSOCIATIVE);
->fetchAllAssociative();

return $this->createNewsArticles($newsArticleRows);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Event/Productions/DBALProductionRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function search(string $keyword, int $start, int $limit): array
$query->setParameter(':keyword', $keyword);
}

$results = $query->execute()->fetchAll();
$results = $query->execute()->fetchAllAssociative();

if (empty($results)) {
return [];
Expand Down Expand Up @@ -154,7 +154,7 @@ public function search(string $keyword, int $start, int $limit): array
public function count(string $keyword): int
{
$keyword = $this->addWildcardToKeyword($keyword);
return count($this->createSearchQuery($keyword)->execute()->fetchAll());
return count($this->createSearchQuery($keyword)->execute()->fetchAllAssociative());
}

private function createSearchQuery(string $keyword): QueryBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private function eventHasRelations(
->setParameter('event_id', $id);

$result = $q->execute();
$relations = $result->fetchAll();
$relations = $result->fetchAllAssociative();

return count($relations) > 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/EventSourcing/DBAL/UniqueDBALEventStoreDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private function executePreflightLookup(string $uniqueValue, string $domainMessa
->where($likeUniqueValue)
->setParameter('uniqueValue', $uniqueValue)
->execute()
->fetchAll();
->fetchAllAssociative();

if (!empty($rows)) {
throw new UniqueConstraintException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,6 @@ private function getResourceCount(string $resourceId): int
->where($this->idField . ' = :resource_id')
->setParameter(':resource_id', $resourceId)
->execute()
->fetchAll());
->fetchAllAssociative());
}
}
2 changes: 1 addition & 1 deletion tests/Contributor/DbalContributorRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public function it_can_overwrite_contributor_and_type(ItemType $itemType): void
->andWhere('type = :type')
->setParameter(':type', $itemType->toString())
->execute()
->fetchAll();
->fetchAllAssociative();

$this->assertEquals(2, count($result));
}
Expand Down

0 comments on commit b09c021

Please sign in to comment.