Answer the question
In order to leave comments, you need to log in
How to filter data by links?
There is a sample, for example, select posts where User ID = 1.
Which approach is more correct:
->where('post.user = :user')
->setParameter('user', User $user) // принимаем класс
//or
->where('post.userId = :userId')
->setParameter('userId', (int) 1) // принимаем ID, только простые типы.
Answer the question
In order to leave comments, you need to log in
The correct second option.
For in the URL parameters you can only pass the id of the object, and not the object itself.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question