Hello.
I have the following question.
I'm doing a select in several different tables, I want to bring some of them. But all the way I try, or it only returns the main or an error.
Can you help me?
$em = $this->getDoctrine()->getManager();
$qb = $em->createQueryBuilder()
->select( ['c as customer','b as bankAccount'] )
->from('MyBundle:BankAccount', 'b')
->join('b.customer', 'c')
->join('c.prepaidCards', 'p')
->leftJoin('c.addresses', 'a', Join::WITH, 'a.type = :address_type')
->leftJoin('a.city', 'ci')
->leftJoin('a.state', 's')
->leftJoin('c.company', 'co')
->where('b.accountType = :account_type')
->andWhere('b.isActive = 1')
->andWhere('p.status = :card_status')
->andWhere('p.shippingType ' . (is_null($shippingType) ? 'IS NULL' : '= :shipping_type'))
->andWhere('c.status IN (:customer_status)')
->setParameter('account_type', BankAccount::ACCOUNT_TYPE_CARD)
->setParameter('card_status', PrepaidCard::CARD_STATUS_ASSIGNED)
->setParameter('address_type', Address::TYPE_SHIPPING);
if (!is_null($shippingType)) {
$qb->setParameter('shipping_type', $shippingType);
}
$result = $qb->setParameter('customer_status', [Customer::STATUS_ACCEPTED, Customer::STATUS_ACTIVATED])
->getQuery()->getResult();
I've tried the excerpt:
->select( ['c as customer','b as bankAccount'] )
How to:
->select( 'c as customer, b as bankAccount' )
->select( ['c','b'] )
->select( 'c','b' )
And some others that I do not remember at the moment.
I need to bring 'c', 'b', 'p', 'a', 'ci', 's'