1$repository = $this->getDoctrine()->getRepository(Product::class);
2
3// look for a single Product by its primary key (usually "id")
4$product = $repository->find($id);
5
6// look for a single Product by name
7$product = $repository->findOneBy(['name' => 'Keyboard']);
8// or find by name and price
9$product = $repository->findOneBy([
10 'name' => 'Keyboard',
11 'price' => 1999,
12]);
13
14// look for multiple Product objects matching the name, ordered by price
15$products = $repository->findBy(
16 ['name' => 'Keyboard'],
17 ['price' => 'ASC']
18);
19
20// look for *all* Product objects
21$products = $repository->findAll();
22
1$service = $repository->findBy(array('name' => 'Registration'),array('name' => 'ASC'),1 ,0)[0];