Antwortmöglichkeit
This commit is contained in:
@@ -80,7 +80,7 @@ class Comment
|
|||||||
*/
|
*/
|
||||||
public function isReply(): bool
|
public function isReply(): bool
|
||||||
{
|
{
|
||||||
return $this->parentCommentId !== null;
|
return $this->parentCommentId !== null && $this->parentCommentId !== 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -113,6 +113,10 @@ class DatabaseCommentManager implements CommentManagerDAO
|
|||||||
try {
|
try {
|
||||||
$db = $this->getConnection();
|
$db = $this->getConnection();
|
||||||
|
|
||||||
|
if ($parentCommentId === "" || $parentCommentId === 0 || $parentCommentId === "0") {
|
||||||
|
$parentCommentId = null;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "
|
$sql = "
|
||||||
INSERT INTO comments (
|
INSERT INTO comments (
|
||||||
article_id,
|
article_id,
|
||||||
@@ -173,12 +177,21 @@ class DatabaseCommentManager implements CommentManagerDAO
|
|||||||
$comments = [];
|
$comments = [];
|
||||||
|
|
||||||
while ($row = $command->fetch(PDO::FETCH_ASSOC)) {
|
while ($row = $command->fetch(PDO::FETCH_ASSOC)) {
|
||||||
|
$parentCommentId = null;
|
||||||
|
|
||||||
|
if (
|
||||||
|
isset($row["parent_comment_id"])
|
||||||
|
&& $row["parent_comment_id"] !== null
|
||||||
|
&& $row["parent_comment_id"] !== ""
|
||||||
|
&& intval($row["parent_comment_id"]) !== 0
|
||||||
|
) {
|
||||||
|
$parentCommentId = intval($row["parent_comment_id"]);
|
||||||
|
}
|
||||||
|
|
||||||
$comments[] = new Comment(
|
$comments[] = new Comment(
|
||||||
intval($row["id"]),
|
intval($row["id"]),
|
||||||
intval($row["article_id"]),
|
intval($row["article_id"]),
|
||||||
isset($row["parent_comment_id"]) && $row["parent_comment_id"] !== null
|
$parentCommentId,
|
||||||
? intval($row["parent_comment_id"])
|
|
||||||
: null,
|
|
||||||
$row["author"],
|
$row["author"],
|
||||||
$row["content"],
|
$row["content"],
|
||||||
$row["created"]
|
$row["created"]
|
||||||
|
|||||||
Reference in New Issue
Block a user