Getting a “true” object from a proxy object in doctrine2

前端 未结 11 1463
南笙
南笙 2021-02-01 13:50

Doctrine uses proxy objects to represent related objects in order to facilitate lazy loading. This is a really cool feature, but its causing an issue with something I am trying

11条回答
  •  孤城傲影
    2021-02-01 14:41

    If you first used $em->getReference and then $em->find, then the result will be a _proxy. I recommend using:

     createQueryBuilder ... ->getQuery()
        ->setHint (Query::HINT_FORCE_PARTIAL_LOAD, true)
        ->getOneOrNullResult();
    

提交回复
热议问题