Skip to content

Commit

Permalink
[FEATURE] Keep sorting order of given uidlist (#25)
Browse files Browse the repository at this point in the history
* [FEATURE] Keep sorting order of given uidlist

Resolves: #23
  • Loading branch information
davidsteeb authored Mar 27, 2024
1 parent 45efa98 commit 191bd58
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Classes/ViewHelpers/GetDatabaseRecordViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,18 @@ public static function renderStatic(array $arguments, \Closure $renderChildrenCl
$table = $arguments['table'] ?? self::DEFAULT_TABLE;
$queryBuilder = self::getQueryBuilder($table);
$splitChar = $arguments['splitChar'] ?? self::DEFAULT_SPLIT_CHAR;
$uids = GeneralUtility::intExplode($splitChar, $arguments['uidList'], true);

$result = $queryBuilder
->select('*')
->from($table)
->where(
$queryBuilder->expr()->in('uid', $queryBuilder->createNamedParameter(explode($splitChar, $arguments['uidList']), Connection::PARAM_INT_ARRAY)),
$queryBuilder->expr()->in('uid', $queryBuilder->createNamedParameter($uids, Connection::PARAM_INT_ARRAY))
)
->execute()
->add('orderBy', 'FIELD(uid,' . implode(',', $uids ) . ')')
->executeQuery()
->fetchAllAssociative();

return $result;
}

Expand Down

0 comments on commit 191bd58

Please sign in to comment.