/** * Add a query to save an individual comment to the transaction * * @param Comment $comment * @param UserInterface $user */ private function _save(Comment $comment, UserInterface $user) { $this->_trans->add("\n\t\t\tUPDATE\n\t\t\t\tblog_comment\n\t\t\tSET\n\t\t\t\tpage_id = :pageID?i,\n\t\t\t\tuser_id = :userID?i,\n\t\t\t\t`name` = :name?s,\n\t\t\t\temail_address = :email?s,\n\t\t\t\twebsite = :website?sn,\n\t\t\t\tcontent = :content?s,\n\t\t\t\tip_address = :ipAddress?s,\n\t\t\t\tupdated_at = :updatedAt?d,\n\t\t\t\tupdated_by = :updatedBy?in,\n\t\t\t\tstatus = :status?s\n\t\t\tWHERE\n\t\t\t\tcomment_id = :id?i\n\t\t", ['id' => $comment->getID(), 'pageID' => $comment->getPageID(), 'userID' => $comment->getUserID(), 'name' => $comment->getName(), 'email' => $comment->getEmail(), 'website' => $comment->getWebsite(), 'content' => $comment->getContent(), 'ipAddress' => $comment->getIpAddress(), 'updatedAt' => new \DateTime(), 'updatedBy' => $user->id, 'status' => $comment->getStatus()]); }
/** * Save a new, individual comment * * @param Comment $comment * @return Comment */ public function save(Comment $comment) { $result = $this->_query->run("\n\t\t\tINSERT INTO\n\t\t\t\tblog_comment\n\t\t\tSET\n\t\t\t\tpage_id = :pageID?i,\n\t\t\t\tuser_id = :userID?in,\n\t\t\t\t`name` = :name?s,\n\t\t\t\temail_address = :email?s,\n\t\t\t\twebsite = :website?sn,\n\t\t\t\tcontent = :content?s,\n\t\t\t\tip_address = :ipAddress?s,\n\t\t\t\tcreated_at = :createdAt?d,\n\t\t\t\tupdated_at = :updatedAt?d,\n\t\t\t\tupdated_by = :updatedBy?in,\n\t\t\t\tstatus = :status?s\n\t\t", ['pageID' => $comment->getPageID(), 'userID' => $comment->getUserID(), 'name' => $comment->getName(), 'email' => $comment->getEmail(), 'website' => $comment->getWebsite(), 'content' => $comment->getContent(), 'ipAddress' => $comment->getIpAddress(), 'createdAt' => new \DateTime(), 'updatedAt' => new \DateTime(), 'updatedBy' => $comment->getUserID(), 'status' => $comment->getStatus()]); $comment->setID($result->id()); return $comment; }