Clean up, fix attribute update query

This commit is contained in:
sctn4elk 2024-06-03 10:12:11 -05:00
parent c67b95240b
commit fc0237ef43
5 changed files with 17 additions and 15 deletions

View File

@ -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 {

View File

@ -1,14 +1,15 @@
<?php
header("Content-Type: multipart/form-data");
header("Access-Control-Allow-Origin: *");
require_once PD . "/Model/ImageModel.php";
/**
* Description of ImageController
*
* @author Mike Howard
*/
header("Content-Type: multipart/form-data");
header("Access-Control-Allow-Origin: *");
require_once PD . "/Model/ImageModel.php";
class ImageController extends BaseController {
public $imageModel;

View File

@ -80,8 +80,8 @@ class AttributeModel extends Database {
$query .= "'" . $jsonPayLoad[$keys[$i]] . "', ";
}
}
$query .= $jsonPayLoad[$keys[$i]] . ")";
$query .= "'" . $jsonPayLoad[$keys[$i]] . "')";
$rowCount = $this->processStatement($query);
return $rowCount;
}

View File

@ -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);
}

View File

@ -72,6 +72,6 @@ class ImageModel extends Database {
public function returnImageBlob()
{
throw New Exception("Not Implemented");
}
}