Skip to content

Commit

Permalink
Fix queryBuilder and result fetching in repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
beatrycze-volk committed Jun 26, 2023
1 parent 1ef3a13 commit 09645a9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
20 changes: 12 additions & 8 deletions Classes/Domain/Repository/MetadataRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public function findBySettings($settings = [])
*/
public function findWithFormat($pid, $type)
{
$query = $this->getQueryBuilder()
$queryBuilder = $this->getQueryBuilder();
$query = $queryBuilder
->select(
self::TABLE . '.index_name AS index_name',
'tx_dlf_metadataformat_joins.xpath AS xpath',
Expand Down Expand Up @@ -103,7 +104,7 @@ public function findWithFormat($pid, $type)
$queryBuilder->expr()->eq('tx_dlf_metadataformat_joins.pid', $pid),
$queryBuilder->expr()->eq('tx_dlf_formats_joins.type', $queryBuilder->createNamedParameter($type))
);
return $query->execute()->fetchAll();
return $query->execute()->fetchAllAssociative();
}

/**
Expand All @@ -115,7 +116,8 @@ public function findWithFormat($pid, $type)
*/
public function findWithoutFormat($pid)
{
$query = $this->getQueryBuilder()
$queryBuilder = $this->getQueryBuilder();
$query = $queryBuilder
->select(
self::TABLE . '.index_name AS index_name',
self::TABLE . '.is_sortable AS is_sortable',
Expand All @@ -130,7 +132,7 @@ public function findWithoutFormat($pid)
$queryBuilder->expr()->neq(self::TABLE . '.default_value', $queryBuilder->createNamedParameter(''))
);

return $query->execute()->fetchAll();
return $query->execute()->fetchAllAssociative();
}

/**
Expand All @@ -150,7 +152,8 @@ public function findQueryPath($pid, $iiifVersion)
* check the configuration.
* TODO Saving / indexing should still work - check!
*/
$query = $this->getQueryBuilder()
$queryBuilder = $this->getQueryBuilder();
$query = $queryBuilder
->select('tx_dlf_metadataformat.xpath AS querypath')
->from(self::TABLE)
->from('tx_dlf_metadataformat')
Expand All @@ -169,7 +172,7 @@ public function findQueryPath($pid, $iiifVersion)
)
);

return $query->execute()->fetchAll();
return $query->execute()->fetchAllAssociative();
}

/**
Expand All @@ -182,7 +185,8 @@ public function findQueryPath($pid, $iiifVersion)
*/
public function findForIiif($pid, $iiifVersion)
{
$query = $this->getQueryBuilder()
$queryBuilder = $this->getQueryBuilder();
$query = $queryBuilder
->select(
self::TABLE . '.index_name AS index_name',
self::TABLE . '.xpath AS xpath',
Expand All @@ -207,7 +211,7 @@ public function findForIiif($pid, $iiifVersion)
)
);

return $query->execute()->fetchAll();
return $query->execute()->fetchAllAssociative();
}

/**
Expand Down
5 changes: 3 additions & 2 deletions Classes/Domain/Repository/StructureRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

namespace Kitodo\Dlf\Domain\Repository;

use Kitodo\Dlf\Common\Helper;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Database\ConnectionPool;

Expand Down Expand Up @@ -43,6 +44,6 @@ public function findThumbnail($cPid, $type)
)
->setMaxResults(1);

return $query->execute()->fetchAll();
return $query->execute()->fetchAllAssociative();
}
}
}

0 comments on commit 09645a9

Please sign in to comment.