Doctrine find方法返回Proxies \ ClassProy

时间:2016-07-27 17:46:18

标签: symfony doctrine repository

我正在使用symfony 2.0.17 我正在尝试使用提供find($id)的方法Doctrine来获取对象。通常,它返回表示数据库行的特定对象实体。但在这种情况下,它返回Proxy表示,我不知道为什么......

这是我的代码:

$em = $this->getDoctrine()->getEntityManager();    
$entity =  $em->getRepository('AppBundle:Entityname')->find($id);
var_dump($entity);die;
...
...

结果如下:

object(Proxies\AppBundleEntityEntitynameProxy)[4648]
public '__isInitialized__' => boolean true
  private 'id' (AppBundle\Entity\Entityname) => int 1
  private 'type' (AppBundle\Entity\Entityname) => null
  private 'name' (AppBundle\Entity\Entityname) => string 'My custom name' (length=19)

提前致谢!

0 个答案:

没有答案