From f9f1e2bf173ee75f6eb9dbb8c94e0bd9ef078cf3 Mon Sep 17 00:00:00 2001 From: "K. Nobel" Date: Tue, 24 Jan 2017 16:40:30 +0100 Subject: [PATCH] Changed select posts query. --- website/queries/user.php | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/website/queries/user.php b/website/queries/user.php index 18cd3f6..25bbf0e 100644 --- a/website/queries/user.php +++ b/website/queries/user.php @@ -68,18 +68,24 @@ function selectAllUserGroups($userID) { function selectAllUserPosts($userID) { $stmt = $GLOBALS["db"]->prepare(" SELECT - `postID`, - `author`, - `title`, - `content`, - `creationdate` + `postID`, + `author`, + `title`, + CASE LENGTH(`content`) >= 150 + WHEN TRUE THEN + CONCAT(LEFT(`content`, 150), '...') + WHEN FALSE THEN + `content` + END + AS `content`, + `creationdate` FROM - `post` + `post` WHERE - `author` = :userID AND - `groupID` IS NULL + `author` = :userID AND + `groupID` IS NULL ORDER BY - `creationdate` DESC + `creationdate` DESC "); $stmt->bindParam(':userID', $userID, PDO::PARAM_INT);