From fc0237ef43d19c24da1006a5ccc65d08d9358dac Mon Sep 17 00:00:00 2001 From: sctn4elk Date: Mon, 3 Jun 2024 10:12:11 -0500 Subject: [PATCH] Clean up, fix attribute update query --- Controller/API/AttributeController.php | 4 ++-- Controller/API/ImageController.php | 11 ++++++----- Model/AttributeModel.php | 4 ++-- Model/Database.php | 11 ++++++----- Model/ImageModel.php | 2 +- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/Controller/API/AttributeController.php b/Controller/API/AttributeController.php index 427ed8b..1293f0f 100644 --- a/Controller/API/AttributeController.php +++ b/Controller/API/AttributeController.php @@ -115,10 +115,10 @@ class AttributeController extends BaseController { $this->attributeModel->attributeId = $input['LOYALTY_ATTRIBUTE_ID']; $result = $this->attributeModel->findMemberAttribute(); - if (! $result) { + if (!$result) { return $this->notFoundResponse("attributeModel->findMemberAttribute"); } - + $response = $this->attributeModel->updateMemberAttribute($input); unset($this->attributeModel->memberId); } else { diff --git a/Controller/API/ImageController.php b/Controller/API/ImageController.php index b44eea9..8bdd23b 100644 --- a/Controller/API/ImageController.php +++ b/Controller/API/ImageController.php @@ -1,14 +1,15 @@ processStatement($query); return $rowCount; } diff --git a/Model/Database.php b/Model/Database.php index 8b668c1..b062a42 100644 --- a/Model/Database.php +++ b/Model/Database.php @@ -24,7 +24,7 @@ class Database { public function processQuery($query = "", $params = []) { try { - $stmt = $this->connection->prepare( $query ); + $stmt = $this->connection->prepare($query); if($stmt === false) { throw New Exception("Unable to do prepared statement: " . $query); } @@ -59,7 +59,8 @@ class Database { $rowCount = $this->connection->affected_rows; if($rowCount < 1) { - throw New Exception("Statement did not return any rows: " . $query); + $msg = "Statement did not return any rows: " . $query; + return $this->unprocessableQueryResponse($msg); } $stmt->close(); @@ -77,18 +78,18 @@ class Database { $result = $this->connection->query($query."(".$imageModel->memberId.", '".$imageModel->imageType."', '".$data."')"); if($result === false) { - $msg = "Unable to execute the statement: " . $query; + $msg = "Unable to execute the statement: " . $data; return $this->unprocessableQueryResponse($msg); } $rowCount = $this->connection->affected_rows; if($rowCount < 1) { - $msg = "Statement did not return any rows: " . $query; + $msg = "Statement did not return any rows: " . $data; return $this->unprocessableQueryResponse($msg); } } catch(Exception $e) { - $msg = $query . " " . $e->getMessage(); + $msg = $data . " " . $e->getMessage(); return $this->unprocessableQueryResponse($msg); } diff --git a/Model/ImageModel.php b/Model/ImageModel.php index 83e2c47..6e01846 100644 --- a/Model/ImageModel.php +++ b/Model/ImageModel.php @@ -72,6 +72,6 @@ class ImageModel extends Database { public function returnImageBlob() { - + throw New Exception("Not Implemented"); } }