Implement feature for deleting posts and improving ajax requests
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user