Basic Fetching
Examples of simple use-cases for reading data.
Reading Data
Example 1: Find by ID, as per doctrine
$policy = $repository->find(19086207);Example 2: Find by child property (not possible in Doctrine)
$policy2 = $repository->findOneBy(['vehicle.regNo' => 'PJ63LXR']);Example 3: Find by child ID, as per doctrine
$policy3 = $repository->findOneBy(['customer' => 14247]);Example 4: Find by child object
//Assuming $customer already holds a customer entity
$policy3 = $repository->findOneBy(['customer' => $customer]);Example 5: Load with LIKE (or any other) operator
$criteria = [
'policyNo' => [
'operator' => 'LIKE',
'value' => 'UKCAR123%'
]
];
$policies = $repository->findBy($criteria);Example 6: Load flat array of data (not bound to entities)
Example 7: Load a single value from a single property of a single entity
Example 8: Load an array of single values from a single property of multiple entities
Last updated