Ruben Lech
Ruben Lech

Reputation: 125

Symfony2 - Doctrine query

I have problem with Doctrine query in my Symfony2 project. That my code:

public function getLender($lender) {
    $lender = str_replace("_", " ", $lender);
    $this->qb->select('ld, ld.entry, ll.name, ll.logo')
        ->from('PageMainBundle:LoanDescription', 'ld')
        ->leftJoin(
           'PageMainBundle:loanLender',
           'll',
           \Doctrine\ORM\Query\Expr\Join::WITH,
           'ld.lender = ll.lenderId'
           )    
        ->where('ll.name=?1')   
        ->setParameter(1, $lender);     
    return $this->qb->getQuery()->getResult();
}

When in select section i choose columns it works very well - returns values of columns. unforunelly when I try something like that:

$this->qb->select('ld')

I don't get pure values but sometkhing strange. How can I get values of all db columns?

Upvotes: 0

Views: 77

Answers (1)

Tomasz Madeyski
Tomasz Madeyski

Reputation: 10910

This "strange" thing is most probably an LoanDescription collection of object (entity) instances. So to get value of entry field you need to call $entity->getEntry() on this entity object (assuming that you have such method defined in your entity)

OR

You can use getArrayResult instead of getResult and you should get array with valies

Upvotes: 3

Related Questions