Refactor
This commit is contained in:
parent
c5c2893201
commit
832765e4a6
1 changed files with 18 additions and 15 deletions
|
@ -26,31 +26,34 @@ switch ($_SERVER['REQUEST_METHOD']) {
|
|||
case 'POST':
|
||||
if (isset($_POST['wishlist'])) {
|
||||
$wishlist = $database
|
||||
->query('SELECT *
|
||||
->query(
|
||||
'SELECT *
|
||||
FROM `wishlists_saved`
|
||||
WHERE `wishlist` = ' . Sanitiser::getNumber($_POST['wishlist']) . '
|
||||
;')
|
||||
WHERE `wishlist` = ' . Sanitiser::getNumber($_POST['wishlist']) . ';'
|
||||
)
|
||||
->fetch();
|
||||
|
||||
if ($wishlist) {
|
||||
/** Delete */
|
||||
$database
|
||||
->query('DELETE FROM `wishlists_saved`
|
||||
WHERE `wishlist` = ' . Sanitiser::getNumber($_POST['wishlist']) . '
|
||||
;');
|
||||
->query(
|
||||
'DELETE FROM `wishlists_saved`
|
||||
WHERE `wishlist` = ' . Sanitiser::getNumber($_POST['wishlist']) . ';'
|
||||
);
|
||||
|
||||
$response['action'] = 'deleted';
|
||||
} else {
|
||||
/** Create */
|
||||
$database
|
||||
->query('INSERT INTO `wishlists_saved` (
|
||||
->query(
|
||||
'INSERT INTO `wishlists_saved` (
|
||||
`user`,
|
||||
`wishlist`
|
||||
) VALUES (
|
||||
' . $_SESSION['user']->id . ',
|
||||
' . Sanitiser::getNumber($_POST['wishlist']) . '
|
||||
)
|
||||
;');
|
||||
);'
|
||||
);
|
||||
|
||||
$response['action'] = 'created';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue