insanelyBlog/includes/comment.class.php

45 lines
1.1 KiB
PHP
Raw Permalink Normal View History

<?php
class comments
{
private $id;
private $comments;
private $replies;
public function __construct($id)
{
if (!isnum($id)) return false;
$this->id = $id;
}
public function get_comments($check = false)
{
if (!$this->comments)
{
global $_sql;
$query = $_sql->query("SELECT `comments`.*, users.userName AS bySlug, users.userPublicName AS byName, users.userPic FROM `comments` INNER JOIN users ON commentBy = userId WHERE commentEntry = ".$this->id." AND commentReply = 0 ORDER BY commentTime DESC");
if ($check)
return $query->num_rows;
else
$this->comments = $query;
}
return $this->comments->fetch_assoc();
}
public function get_replies($check = false)
{
if (!$this->replies)
{
global $_sql;
$query = $_sql->query("SELECT `comments`.*, users.userName AS bySlug, users.userPublicName AS byName, users.userPic FROM `comments` INNER JOIN users ON commentBy = userId WHERE commentReply = ".$this->id." ORDER BY commentTime DESC");
if ($check)
return $query->num_rows;
$this->replies = $query;
}
return $this->replies->fetch_assoc();
}
2016-06-18 10:07:35 +02:00
}