[MODM-144] Bi-Directional References Feature Created: 18/May/11  Updated: 18/May/11

Status: Open
Project: Doctrine MongoDB ODM
Component/s: None
Affects Version/s: 1.0.0BETA3
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Jan Gantzert Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
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


Generated at Mon Jul 28 20:38:57 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.