I am using symfony 1.4 with Doctrine ORM. I am editing some of the actions, and I need to rewrite a Propel query into Doctrine. Here's the snippet:
$c = new Criteria();
$c->add(BlogCommentPeer::BLOG_POST_ID, $request->getParameter('id'));
$c->addAscendingOrderByColumn(BlogCommentPeer::CREATED_AT);
$this->comments = BlogCommentPeer::doSelect($c);
Can anyone help with the conversion? Thanks.
In your BlogCommentTable.php
file, put this method :
public functoion retrieveByPostId($post_id)
{
$q = $this->createQuery('c')
->where('c.blog_post_id = ?', array($post_id))
->orderBy('c.created_at ASC');
return $q->execute();
}
And in your action:
$this->comments = Doctrine_Core::getTable('BlogComment')->retrieveByPostId($request->getParameter('id'));