我是Symfony/Doctrine的新手。 我创建了2个实体来管理附加到它们的一些注释和文档: 这里是comment entity,这里comment document entity。 现在的问题是从数据库这样获取数据时:Symfony2学说关联结果
$comment = $em->getRepository('PathToBundle:Comment')->findOneBy(
array('ordernumber' => '123456')
);
,并让我们说我wan't调试它,所以我
print_r($comment);
它打印的出这样的事:
Path\ToBundle\Entity\Comment Object
(
[id:Path\ToBundle\Entity\Comment:private] => 1
[ordernumber:Path\ToBundle\Entity\Comment:private] => 123456
[category:Path\ToBundle\Entity\Comment:private] => cat1
[comment:Path\ToBundle\Entity\Comment:private] => com1
[user:Path\ToBundle\Entity\Comment:private] => usr1
[version:Path\ToBundle\Entity\Comment:private] => 0
[documents:Path\ToBundle\Entity\Comment:private] => Doctrine\ORM\PersistentCollection Object
(
[snapshot:Doctrine\ORM\PersistentCollection:private] => Array
(
)
[owner:Doctrine\ORM\PersistentCollection:private] => Path\ToBundle\Entity\Comment Object
*RECURSION*
[association:Doctrine\ORM\PersistentCollection:private] => Array
(
[fieldName] => documents
[mappedBy] => comment
[targetEntity] => Path\ToBundle\Entity\CommentDocument
[cascade] => Array
(
)
[orphanRemoval] =>
[fetch] => 2
[type] => 4
[inversedBy] =>
[isOwningSide] =>
[sourceEntity] => Path\ToBundle\Entity\Comment
[isCascadeRemove] =>
[isCascadePersist] =>
[isCascadeRefresh] =>
[isCascadeMerge] =>
[isCascadeDetach] =>
)
它刚刚开始,它一直持续到浏览器崩溃。但如果尝试访问单个属性,如
print_r($input->getComment());
它工作正常。
那么这种行为是否正常,或者我做错了什么?我怎样才能访问关联的文档表值?