Skip to content

Commit 0cb5675

Browse files
author
a001
committed
CRUD Comment
1 parent 6553483 commit 0cb5675

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

lib/CommentMapper.php

100644100755
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,35 @@ public function addComment(Comment $comment)
5454
$STH->execute();
5555
$comment->setID($this->DBH->lastInsertId());
5656
}
57+
58+
public function getCommentsByNode($node)
59+
{
60+
61+
$STH = $this->DBH->prepare("SELECT * FROM comments WHERE fileid=:id and path LIKE (:node,'%') ORDER BY path");
62+
$STH->bindValue(":id", $id);
63+
$STH->bindValue(":node", $node);
64+
$STH->execute();
65+
return $STH->fetchAll(PDO::FETCH_CLASS, "comment");
66+
}
67+
68+
public function deleteComment($node)
69+
{
70+
$STH = $this->DBH->prepare("DELETE FROM comments WHERE path LIKE (:node,'%')");
71+
$STH->execute();
72+
}
73+
74+
public function editeComment(Comment $comment)
75+
{
76+
$STH = $this->DBH->prepare("UPDATE comments SET (text)
77+
VALUES (:text) WHERE id:=:id");
78+
79+
$STH->bindvalue(":id", $comment->getID());
80+
$STH->bindvalue(":text", $comment->getText());
81+
82+
83+
$STH->execute();
84+
$comment->setID($this->DBH->lastInsertId());
85+
}
86+
}
5787

5888
}

0 commit comments

Comments
 (0)