0

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.

1 Answer 1

1

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'));
Sign up to request clarification or add additional context in comments.

1 Comment

oops. sorry. kinda new to this and still figuring out the rules of engagement.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.