Exemple #1
0
 /**
  * Inserts comment into database.
  * @param int $userId Id of user who is posting the comment.
  * @param string $comment Comment text.
  * @return string JSON encoded string that consist of 3 fields:
  * user,comment and postTime
  */
 public function insertComment($userId, $comment)
 {
     $user = new ASUser($userId);
     $userInfo = $user->getInfo();
     $datetime = date("Y-m-d H:i:s");
     $this->db->insert("as_comments", array("posted_by" => $user->id(), "posted_by_name" => $userInfo['username'], "comment" => strip_tags($comment), "post_time" => $datetime));
     $result = array("user" => $userInfo['username'], "comment" => stripslashes(strip_tags($comment)), "postTime" => $datetime);
     return json_encode($result);
 }