Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CWD
CwdDataDoctrineORMBundle
Commits
b98cd650
Commit
b98cd650
authored
Jan 09, 2019
by
Bernhard Schussek
Browse files
Maintain order of IDs passed to getMultiple()
parent
76cbadcd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Repository/ORMRepository.php
View file @
b98cd650
...
...
@@ -137,14 +137,19 @@ abstract class ORMRepository extends EntityRepository implements EditableReposit
return
new
EmptyCursor
();
}
$idStrings
=
array_map
(
'strval'
,
array_values
(
$ids
));
// Index by ID for the ID check below
$aggregates
=
$this
->
createQueryBuilder
(
'e'
,
sprintf
(
'e.%s'
,
$this
->
idField
))
->
where
(
sprintf
(
'e.%s IN (:ids)'
,
$this
->
idField
))
->
setParameter
(
'ids'
,
array_map
(
'strval'
,
array_values
(
$ids
))
)
->
setParameter
(
'ids'
,
$idStrings
)
->
getQuery
()
->
execute
();
$cursor
=
new
ArrayCursor
(
$aggregates
);
// Maintain the order of IDs
$sortedAggregates
=
array_replace
(
array_flip
(
$idStrings
),
$aggregates
);
$cursor
=
new
ArrayCursor
(
$sortedAggregates
);
if
(
$ignoreMissing
)
{
return
$cursor
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment