Answer the question
In order to leave comments, you need to log in
Is it correct to pass the Entity object to the repository method, or is it better to pass specific primitive values?
You need to pass Entity or concrete types to the method, as in this case. Which is more correct?
public function getSimilar(int $specializationId, int $currentId)
{
$v = $this
->createQueryBuilder('v')
->where('specialization_id = : specializationId')
->andWhere('id <> ' . $currentId)
->setParameters([
'specializationId' => $specializationId,
'id' => $currentId,
])
->orderBy('expirationDate DESC', 'bonus DESC')
->setMaxResults(2)
->getQuery()
->getResult();
}
Answer the question
In order to leave comments, you need to log in
Call the repository method with entity field values as arguments..
$SomeEntytyREpo->getSimilar($Entity->getId(), $Entity->getOneMoreFieldValue)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question