I try to create custom finder in Repository class. And the where condition is find posts what created not by current user. But I still geting all posts. Here is the code:
public function selectRelatedTrips($assoc, $profileId)
{
$params = array();
$query = $this
->getEntityManager()
->createQueryBuilder()
->select('t')
->from('VputiTripBundle:Trip', 't')
->where('t.profile != :profile');
$params['profile']=$profileId;
foreach ($assoc as $k => $v) {
$query->orWhere('t.startCity = :param' . $k);
$query->orWhere('t.targetCity = :param' . $k);
$params['param' . $k] = $v;
}
return $query->setParameters($params)
->setMaxResults(20)
->orderBy('t.id', 'desc')
->getQuery()
->getResult();
}
What I am doing wrong?