简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM