I have a controller action as follows
public function reportcommentAction() {
$comment_id = $this->getRequest()->comment_id;
$blockedCommentTable = new Application_Model_DbTable_BlockedComments();
$blockedCommentTable->blockComment($comment_id, $this->user_id);
}
which makes a call to the blockComment() dbTable model which looks like this
class Application_Model_DbTable_BlockedComments extends Zend_Db_Table_Abstract {
protected $_name = 'blocked_comments';
public function blockComment($comment_id, $blocked_by) {
if (!empty($comment_id) && !empty($blocked_by)) {
$data = array(
'comment_id' => $comment_id,
'blocked_by' => $blocked_by
);
$this->insert($data);
exit;
}
}
For some reason, I need that exit; at the end. Without it I get 2 records inserted instead of just the one as expected.
I have 3 fields in the blocked_comments table, i.e. id, comment_id and blocked by. With the exit statement in place I get a record with values 1, 21, 1 as expected. Without the exit statement I get an extra record with values 2, 0, 1 for some reason.
I have the same code ( without the superfluous exit) working in other parts of my code and I have no idea what is going on here.