In my quest to edit data from the inverse side of a ManyToOne - OneToMany
relation, and to avoid fetching the whole table's content, I want to fetch data from a list of IDs.
While this would work,
$data=array();
foreach($idList as $id) {
array_push($data, $em->getRepository(Entity::class)->findBy(array('id', $id)));
}
It would do as many queries as there are IDs.
Before making my own query in the repository, I would like to know if it's possible to use multiple IDs with findBy
.
If it's possible, how do I do it?
You can do
$em->getRepository(Entity::class)->findBy(array('id' => $idList));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With