I have a database it looks like this:
Entity: Post, Comment.. Comment has a foreign key post_id.
I need to get Comments that belongs to specific post by its ID. And sort it by getCreated() metod.
Problem is, when i try to find all comments by post_id like:
$comments = $this->get('doctrine')->getRepository('BlogCommonBundle:Comment')->findBypost_id($postID);
usort($comments, function($a, $b){
return ($a->getCreated() < $b->getCreated());
});
Im gettig ..CommonBundle\Entity\Comment' has no field 'postId'.
Probably because its foreign key.
Is there any way, how to do it?
Thanks a lot!
findBy(array('IDENTITY(comment)' => $postID)), although I'm not sure if you can use the IDENTITY function within findBy...so you might need to create a query builder instead.