stories/app/includes/classes/Comment.php

48 lines
1.4 KiB
PHP
Executable File

<?php
class Comment {
private $con, $sqlData;
public function __construct($con, $input) {
$this->con = $con;
if(is_array($input)) {
$this->sqlData = $input;
}
else {
// $query = $this->con->prepare("SELECT * FROM videos WHERE id = :id OR url = :url");
$query = $this->con->prepare("SELECT * FROM comments WHERE comments_url = :url");
$query->bindParam(":url", $input);
$query->execute();
$this->sqlData = $query->fetch(PDO::FETCH_ASSOC);
}
}
public function getCommentId() {
return $this->sqlData["id"];
}
public function getCommentUrl() {
return $this->sqlData["comment_url"];
}
public function getCommentAuthor() {
return $this->sqlData["comment_author"];
}
public function getCommentBody() {
return $this->sqlData["comment_body"];
}
public function getCommentTimestamp() {
$rawDate = $this->sqlData["comment_timestamp"];
return date('M j Y g:i A', strtotime($rawDate));
}
public function getCommentPostUrl() {
return $this->sqlData["comment_onPost"];
}
}
?>