Archived
1
0

Implement feature for deleting posts and improving ajax requests

This commit is contained in:
Marcel
2018-10-17 13:56:22 +02:00
parent b32b2790c8
commit 334aa22362
23 changed files with 193 additions and 96 deletions

View File

@@ -39,6 +39,15 @@
return $insertedPost[0]['ID'];
}
public function deletePost($userID, $uuid) {
$postID = $this->db->query('SELECT ID FROM user_posts WHERE user_id = ? AND uuid = ?', [$userID, $uuid])->result_array()[0]['ID'];
$this->db->query('DELETE FROM user_posts WHERE user_id = ? AND uuid = ?', [$userID, $uuid]);
$this->db->query('DELETE FROM user_posts_hashtags WHERE postID = ?', [$postID]);
$this->db->query('DELETE FROM user_posts_mentions WHERE postID = ?', [$postID]);
$this->db->query('DELETE FROM user_posts_likes WHERE postID = ?', [$postID]);
$this->db->query('DELETE FROM user_posts_media WHERE postID = ?', [$postID]);
}
public function addImageToPost($postID, $imageUrl) {
$this->db->query('INSERT INTO user_posts_media (postID, mediaType, mediaUrl) VALUES (?, ?, ?)', [$postID, 'image', $imageUrl]);
}
@@ -284,7 +293,9 @@
}
public function getPostByUUID($uuid) {
$this->db->cache_off();
$result = $this->db->query('SELECT * FROM user_posts WHERE uuid = ?', [$uuid])->result_array();
$this->db->cache_on();
return $result;
}