나는 Repository 클래스에서 custom finder를 만들려고한다. 그리고 where 조건은 현재 사용자가 생성하지 않은 것을 찾습니다. 그러나 나는 아직도 모든 포스트를 얻는다. 다음은 코드입니다.같지 않은 조건이 작동하지 않는다 Symfony2
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();
}
내가 뭘 잘못하고 있니? t.profile
엔티티 인 경우
것은 당신도 제대로'setParameter' 호출을 (예 :'-> setParameter를 ('프로필', $ theValue) ')? –
@Elias Van Ootegem, 전체 기능을 추가합니다 – nowiko
't.profile'과'$ profileId'의 유형은 동일합니까? – devilcius