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

前端 未结 11 1562
南笙
南笙 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:43

    Doctrines lazy loading is very good at its job, and will replace a proxy object with a real one as soon as you try to use it or any of its properties. If you are having issues due to the proxy objects (like I did in my question) you most probably have an error in your model.

    That said, you can tell doctrine to pull all the related data by telling it to "hydrate": $query->getResult(Doctrine\ORM\Query::HYDRATE_ARRAY);

提交回复
热议问题