Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
CwdDataDoctrineORMBundle
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Code Review
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
CWD
CwdDataDoctrineORMBundle
Commits
b98cd650
Commit
b98cd650
authored
Jan 09, 2019
by
Bernhard Schussek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Maintain order of IDs passed to getMultiple()
parent
76cbadcd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
Repository/ORMRepository.php
Repository/ORMRepository.php
+7
-2
No files found.
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