我是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());
它工作正常。
那麼這種行爲是否正常,或者我做錯了什麼?我怎樣才能訪問關聯的文檔表值?