How to get association foreign key IDs in Doctrine 2 without loading the associated object?

前端 未结 1 817
醉梦人生
醉梦人生 2020-12-30 10:25

Hi I\'m having trouble with what I thought would be an easy task.

I am retrieving a post from the database. The Post entity has a field createdBy which is associated

相关标签:
1条回答
  • 2020-12-30 11:00

    Use this on your query:

    $q->setHint(\Doctrine\ORM\Query::HINT_INCLUDE_META_COLUMNS, true);
    $q->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY);
    

    Hydratation is disabled, so you have your result as an array.

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