Chat is now only loading the last 100 messages

This commit is contained in:
Lars van Hijfte
2017-02-03 00:24:38 +01:00
parent ab21226925
commit 6d739a4480

View File

@@ -6,18 +6,23 @@ function getOldChatMessages($user2ID) {
if (getFriendshipStatus($user2ID) == 1) { if (getFriendshipStatus($user2ID) == 1) {
$stmt = prepareQuery(" $stmt = prepareQuery("
SELECT SELECT
* *
FROM FROM
`private_message` (SELECT
WHERE *
`origin` = :user1 AND FROM
`destination` = :user2 OR `private_message`
`origin` = :user2 AND WHERE
`destination` = :user1 `origin` = :user1 AND
`destination` = :user2 OR
`origin` = :user2 AND
`destination` = :user1
ORDER BY
`messageID` DESC
LIMIT
100) sub
ORDER BY ORDER BY
`creationdate` ASC `messageID` ASC
LIMIT
100
"); ");
$stmt->bindParam(":user1", $user1ID); $stmt->bindParam(":user1", $user1ID);
@@ -76,7 +81,7 @@ function getNewChatMessages($lastID, $destination) {
`destination` = :user1) AND `destination` = :user1) AND
`messageID` > :lastID `messageID` > :lastID
ORDER BY ORDER BY
`creationdate` ASC `messageID` ASC
"); ");
$stmt->bindParam(':user1', $_SESSION["userID"]); $stmt->bindParam(':user1', $_SESSION["userID"]);