From b3df9d039d6697738782f22dd4c6a05835c1a929 Mon Sep 17 00:00:00 2001 From: Miguel Ribeiro Date: Mon, 8 Jul 2024 11:10:31 +0200 Subject: [PATCH] fix: broken subscription update query --- endpoints/subscription/add.php | 18 +++++++++--------- includes/version.php | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/endpoints/subscription/add.php b/endpoints/subscription/add.php index 0715e5076..b25d0a655 100644 --- a/endpoints/subscription/add.php +++ b/endpoints/subscription/add.php @@ -198,19 +198,16 @@ function resizeAndUploadLogo($uploadedFile, $uploadDir, $name, $settings) $sql = "UPDATE subscriptions SET name = :name, logo = :logo, price = :price, currency_id = :currencyId, next_payment = :nextPayment, cycle = :cycle, frequency = :frequency, notes = :notes, payment_method_id = :paymentMethodId, payer_user_id = :payerUserId, category_id = :categoryId, notify = :notify, inactive = :inactive, - url = :url, notify_days_before = :notifyDaysBefore, camcelation_date = :cancellationDate WHERE id = :id AND user_id = :userId"; + url = :url, notify_days_before = :notifyDaysBefore, cancellation_date = :cancellationDate WHERE id = :id AND user_id = :userId"; } else { - $sql = "UPDATE subscriptions SET name = :name, price = :price, currency_id = :currencyId, next_payment = :nextPayment, - cycle = :cycle, frequency = :frequency, notes = :notes, payment_method_id = :paymentMethodId, payer_user_id = :payerUserId, - category_id = :categoryId, notify = :notify, inactive = :inactive, url = :url, notify_days_before = :notifyDaysBefore, - cancellation_date = :cancellationDate WHERE id = :id AND user_id = :userId"; + $sql = "UPDATE subscriptions SET name = :name, price = :price, currency_id = :currencyId, + next_payment = :nextPayment, cycle = :cycle, frequency = :frequency, notes = :notes, payment_method_id = :paymentMethodId, + payer_user_id = :payerUserId, category_id = :categoryId, notify = :notify, inactive = :inactive, + url = :url, notify_days_before = :notifyDaysBefore, cancellation_date = :cancellationDate WHERE id = :id AND user_id = :userId"; } } $stmt = $db->prepare($sql); - if ($isEdit) { - $stmt->bindParam(':id', $id, SQLITE3_INTEGER); - } $stmt->bindParam(':name', $name, SQLITE3_TEXT); if ($logo != "") { $stmt->bindParam(':logo', $logo, SQLITE3_TEXT); @@ -228,8 +225,11 @@ function resizeAndUploadLogo($uploadedFile, $uploadDir, $name, $settings) $stmt->bindParam(':inactive', $inactive, SQLITE3_INTEGER); $stmt->bindParam(':url', $url, SQLITE3_TEXT); $stmt->bindParam(':notifyDaysBefore', $notifyDaysBefore, SQLITE3_INTEGER); - $stmt->bindParam(':userId', $userId, SQLITE3_INTEGER); $stmt->bindParam(':cancellationDate', $cancellationDate, SQLITE3_TEXT); + if ($isEdit) { + $stmt->bindParam(':id', $id, SQLITE3_INTEGER); + } + $stmt->bindParam(':userId', $userId, SQLITE3_INTEGER); if ($stmt->execute()) { $success['status'] = "Success"; diff --git a/includes/version.php b/includes/version.php index 83de57a2f..f54ba72b1 100644 --- a/includes/version.php +++ b/includes/version.php @@ -1,3 +1,3 @@ \ No newline at end of file