I have an array ($newsList
) of IDs with the following values: 4,2,1,3
.
I'm trying to get some data from the database from entity:
$news=$this->getDoctrine()->getRepository('Bundle:News')->findBy(array('id' => $newsList));
$newsList
array represents real IDs from the News entity.
But when I do:
foreach($news as $n){
$n->getId();
}
IDs are in order: 1,2,3,4
.
How can I preserve the order from beginning in foreach?