0
私は学校のためのプロジェクトを行っていますが、Instagramと似ています。あなたのタイムラインに写真を投稿すると、他のユーザーがこの写真にコメントを付けることができます。PHPの特定の投稿にコメントを付けます。投稿IDはURLに記載されています
このコメントオプションは正常に実行されました。コメントを付けることができ、コメントはデータベースに送られます。
コメントクラッセ:PHPコード
<?php
include_once "Db.class.php";
class Comment
{
private $m_sComment;
public function __set($p_sProperty, $p_vValue)
{
switch($p_sProperty)
{
case "Comment":
$this->m_sComment = $p_vValue;
break;
}
}
public function __get($p_sProperty)
{
$vResult = null;
switch($p_sProperty)
{
case "Comment":
$vResult = $this->m_sComment;
break;
}
return $vResult;
}
public function Save() {
$conn = Db::getInstance();
//$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$statement = $conn->prepare('INSERT INTO comment(comment, postID) VALUES(:comment, :postID)');
$statement->bindValue(':comment', $this->Comment);
$statement->bindValue(':userID', $this->Comment);
$statement->execute();
}
public function GetRecentActivities($p_iPostID) {
$conn = Db::getInstance();
$allComments = $conn->query("SELECT * FROM comment WHERE postID = <post_id> ORDER BY id DESC;");
return $allComments;
}
}
?>
しかし、今の質問は:ポストのURLで、私は特定のPOSTIDを送信します。 http://localhost/oefening/post.php?p=9&u=8
P => PostID
U =>私は自分のデータベースにTIS postIDを送ることができますどのようにユーザーID
?