0
"inventoryLcoation_id"열에 하나 이상의 관계가있는 엔터티가 있습니다. 어떤 이유로 createQueryBuilder()를 사용할 때 내 ajax 호출에서 해당 값을 반환하지 않지만 다른 모든 것을 반환합니다 (예 : id, name 등). 이것은 Symfony2의 문제점이 아닙니다. 지식 부족으로 인한 문제입니다. :) 여기Symfony2 쿼리 작성기가 여러 값을 반환하지 않음
내 쿼리 빌더 코드 :
$qb = $this
->createQueryBuilder('p')
->select('p.id', 'p.name')
->where('p.inventoryLocation = :inventoryId')
->andWhere('p.account = :account_id')
->setParameter('inventoryId', $value)
->setParameter('account_id', $account_id)
->orderBy('p.id', 'DESC');
if($qb->getQuery()->getArrayResult()){
return $qb->getQuery()->getArrayResult();
}else{
return false;
}
내가 그것은 또한 열 값 "inventoryLocation_id"에 매핑 된 inventoryLocation 테이블에서 값을 포함하도록 코딩해야합니까?
Symfony2의 놀라운 세계에 대한 이해를 돕는 데 많은 도움을 주신 데 대해 감사드립니다.
$qb->join('p.inventoryLocation','i')
과 선택에
especify 두 기관$qb->select('p','i')
그것은 다음과 같아야합니다 :
$qb = $this
->createQueryBuilder('p')
->select('p','i')
->join('p.inventoryLocation','i')
->where('p.inventoryLocation = :inventoryId') // or ->where('i = :inventoryId')
->andWhere('p.account = :account_id')
->setParameter('inventoryId', $value)
->setParameter('account_id', $account_id)
->orderBy('p.id', 'DESC');