Why does Doctrine\ORM\Configuration's “DoctrineProxies” Object contain the Universe?

前端 未结 2 763
春和景丽
春和景丽 2021-01-28 06:36

In my ORM code I have an Entity with a field fined like so:

//part of entity class Item:
/** @Column(name=\"product_id\", type=\"integer\") */
private $productId         


        
2条回答
  •  佛祖请我去吃肉
    2021-01-28 07:08

    DoctrineProxies\__CG__\Application\Entity\Product is a proxy class... which means that doctrine doesn't actually fetch the entity from the database (for performance) unless it is needed (i.e. calling $product->getName() those proxy Classes are in a recursive loop with eachother and are VERY large as you saw... most of the information there you don't really need unless you are diving deep ... you should never use print_r ... in the new symfony 2.7+ i think there is a function called dump() in debug mode ... if you use that to print the entity it has loop protection and it just shows reference numbers ... you can also use the \Doctrine\Common\Util\Debug::dump() that also will print out a smaller list than 2^234234234 lines ...

提交回复
热议问题