Skip to content

Instantly share code, notes, and snippets.

@eminetto
Created November 4, 2012 14:11
Show Gist options
  • Save eminetto/4012081 to your computer and use it in GitHub Desktop.
Save eminetto/4012081 to your computer and use it in GitHub Desktop.
/**
* Retorna os comentários de um post
* @return Zend\Http\Response
*/
public function commentsAction()
{
$id = (int) $this->params()->fromRoute('id', 0);
$where = array('post_id' => $id);
$comments = $this->getTable('Application\Model\Comment')
->fetchAll(null, $where)
->toArray();
$response = $this->getResponse();
$response->setStatusCode(200);
$response->setContent(json_encode($comments));
$response->getHeaders()->addHeaderLine('Content-Type', 'application/json');
return $response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment