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':
|
case 'POST':
|
||||||
if (isset($_POST['wishlist'])) {
|
if (isset($_POST['wishlist'])) {
|
||||||
$wishlist = $database
|
$wishlist = $database
|
||||||
->query('SELECT *
|
->query(
|
||||||
FROM `wishlists_saved`
|
'SELECT *
|
||||||
WHERE `wishlist` = ' . Sanitiser::getNumber($_POST['wishlist']) . '
|
FROM `wishlists_saved`
|
||||||
;')
|
WHERE `wishlist` = ' . Sanitiser::getNumber($_POST['wishlist']) . ';'
|
||||||
|
)
|
||||||
->fetch();
|
->fetch();
|
||||||
|
|
||||||
if ($wishlist) {
|
if ($wishlist) {
|
||||||
/** Delete */
|
/** Delete */
|
||||||
$database
|
$database
|
||||||
->query('DELETE FROM `wishlists_saved`
|
->query(
|
||||||
WHERE `wishlist` = ' . Sanitiser::getNumber($_POST['wishlist']) . '
|
'DELETE FROM `wishlists_saved`
|
||||||
;');
|
WHERE `wishlist` = ' . Sanitiser::getNumber($_POST['wishlist']) . ';'
|
||||||
|
);
|
||||||
|
|
||||||
$response['action'] = 'deleted';
|
$response['action'] = 'deleted';
|
||||||
} else {
|
} else {
|
||||||
/** Create */
|
/** Create */
|
||||||
$database
|
$database
|
||||||
->query('INSERT INTO `wishlists_saved` (
|
->query(
|
||||||
`user`,
|
'INSERT INTO `wishlists_saved` (
|
||||||
`wishlist`
|
`user`,
|
||||||
) VALUES (
|
`wishlist`
|
||||||
' . $_SESSION['user']->id . ',
|
) VALUES (
|
||||||
' . Sanitiser::getNumber($_POST['wishlist']) . '
|
' . $_SESSION['user']->id . ',
|
||||||
)
|
' . Sanitiser::getNumber($_POST['wishlist']) . '
|
||||||
;');
|
);'
|
||||||
|
);
|
||||||
|
|
||||||
$response['action'] = 'created';
|
$response['action'] = 'created';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue