public function saveComment(Comment $comment) { $data = ['news_id' => $comment->getNewsId(), 'account_id' => $comment->getAccountId(), 'content' => $comment->getContent(), 'date_posted' => $comment->getDatePosted()]; $id = $comment->getid(); if ($id == 0) { $this->tableGateway->insert($data); } else { if ($this->getComment($id)) { $this->tableGateway->update($data, ['id' => $id]); } else { throw new \Exception('Comment id does not exist'); } } }