Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: 1.0.0BETA3
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Environment:Zend Framework 1.11.6
Description
I cant´t reproduce the Bi-Directional References with my own example or the example of the documentation.
Perhaps the documentation is not up to date or their ist a bug.
BlogPost.php
<?php
/** @Document */
class BlogPost
{
/** @Id */
public $id;
/** @String */
public $title;
/** @String */
public $content;
/** @String */
public $createtime;
/** @String */
public $updatetime;
/** @ReferenceMany(targetDocument="PostComment", mappedBy="post") */
private $comments;
}
PostComment.php
<?php
/** @Document */
class PostComment
{
/** @Id */
public $id;
/** @String */
public $name;
/** @String */
public $mail;
/** @String */
public $content;
/** @String */
public $createtime;
/** @String */
public $updatetime;
/** @ReferenceOne(targetDocument="BlogPost", inversedBy="comments") */
private $post;
}
CommentController.php
// Save the Post
$post = new BlogPost();
$post->setTitle = 'testtitle';
//$post->content = 'testcontent';
//$post->createdate = time();
$comment1 = new PostComment();
$comment1->title = 'testcommenttitle1';
$comment2 = new PostComment();
$comment2->title = 'testcommenttitle2';
$comment3 = new PostComment();
$comment3->title = 'testcommenttitle3';
$dm->persist($comment1);
$dm->persist($comment2);
$dm->persist($comment3);
$dm->flush();
echo $post->id;
/*$posts = $dm->createQueryBuilder('BlogPost')
->getQuery();*/
$post = $dm->getRepository('BlogPost')->find('4dd45739f563724c23000002');
Zend_Debug::dump($post);
$comments = $post->getComments();
------------------------
In the documentation the example is
$post1->setUser($user);
But the only working for me is:
$post->setTitle = 'testtitle';
Anyway, I can´t get the Comments from the mongodb.
I always get this error.
Fatal error: Call to undefined method BlogPost::getComments()
This is a correct error message because BlogPost really dont have a getComments()
method. How do I get my Comments then?
Any help would be great.
Greetings tronga