diff --git a/website/public/chat.php b/website/public/chat.php index f077a4d..150638d 100644 --- a/website/public/chat.php +++ b/website/public/chat.php @@ -5,6 +5,7 @@ +
prepare(" + SELECT + * + FROM + `private_message` + WHERE + `origin` = :user1 AND + `destination` = :user2 OR + `origin` = :user2 AND + `destination` = :user1 + ORDER BY + `creationdate` DESC + LIMIT + :n, 100 + "); + + $stmt->bindParam(":user1", $user1ID); + $stmt->bindParam(":user2", $user2ID); + $stmt->bindParam(":n", $n); + + return $stmt->execute(); +} + +function sendMessage($destination, $content) { + $db = $GLOBALS["db"]; + $stmt = $db->prepare(" + INSERT INTO + `private_message` + ( + `origin`, + `destination`, + `content` + ) + VALUES + ( + :origin, + :destination, + :content + ) + "); + + return $stmt->execute(array( + "origin" => 2, + "destination" => $destination, + "content" => $content + )); +} \ No newline at end of file diff --git a/website/views/chat-view.php b/website/views/chat-view.php index a23a1c5..6b6aecd 100644 --- a/website/views/chat-view.php +++ b/website/views/chat-view.php @@ -37,16 +37,20 @@