Return foreign key with DQL query

后端 未结 1 794
醉酒成梦
醉酒成梦 2021-02-09 08:19

I\'ve got an InvoiceItem entity like this:

/**
 * @Entity
 */
class InvoiceItem
{
    [..]

    /**
     * @ManyToOne(targetEntity=\"Invoice\", inversedBy=\"item         


        
1条回答
  •  不思量自难忘°
    2021-02-09 08:48

    You can use the setHint() method to make the foreign key get returned with the rest of the values for your entity. You apply the method to the query (not the querybuilder):

    $q = $qb->getQuery();
    $q->setHint(\Doctrine\ORM\Query::HINT_INCLUDE_META_COLUMNS, true);
    

    0 讨论(0)
提交回复
热议问题