static function receiveComments() { $database = DB::getInstance(); if (isset($_POST['comment']) && !empty($_POST['comment']) && isset($_POST['team_id']) && !empty($_POST['team_id'])) { $text = $database->real_escape_string(stripslashes($_POST['comment'])); $teamId = $database->real_escape_string(stripslashes($_POST['team_id'])); // creates a comment and stores it in the DB $teamComment = TeamComment::fromText($text, $teamId); } header('Location: ' . '?/TeamProfile/Team/' . $teamId); }
function downloadComments() { $database = DB::getInstance(); $qFetchComments = ' SELECT team_comment.* FROM team_comment WHERE team_comment.team_id = ' . $this->id . ' ORDER BY team_comment.date DESC '; $result = $database->query($qFetchComments); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { // $this->comments[] = ['text' => 'hejsan']; $this->comments[] = TeamComment::withId($row['id']); } } elseif ($error = $database->error) { echo "Failed to get comments from DB " . $error; } }