Work on attributes

This commit is contained in:
sctn4elk 2024-06-03 00:18:25 -05:00
parent 3e20b57008
commit c67b95240b
4 changed files with 19 additions and 8 deletions

View File

@ -113,6 +113,7 @@ class AttributeController extends BaseController {
if ($input['LOYALTY_MEMBER_ID'] != null) { if ($input['LOYALTY_MEMBER_ID'] != null) {
$this->attributeModel->memberId = $input['LOYALTY_MEMBER_ID']; $this->attributeModel->memberId = $input['LOYALTY_MEMBER_ID'];
$this->attributeModel->attributeId = $input['LOYALTY_ATTRIBUTE_ID']; $this->attributeModel->attributeId = $input['LOYALTY_ATTRIBUTE_ID'];
$result = $this->attributeModel->findMemberAttribute(); $result = $this->attributeModel->findMemberAttribute();
if (! $result) { if (! $result) {
return $this->notFoundResponse("attributeModel->findMemberAttribute"); return $this->notFoundResponse("attributeModel->findMemberAttribute");

View File

@ -24,7 +24,10 @@ class AttributeModel extends Database {
public function findMemberAttribute() public function findMemberAttribute()
{ {
return $this->processQuery("SELECT * FROM loyalty_member_view WHERE loyalty_member_id = ? AND loyalty_attribute_id = ?", ["ii", $this->memberId, $this->attributeId]); $query = "SELECT * FROM loyalty_member_view WHERE loyalty_member_id = " . $this->memberId;
$query .= " AND loyalty_attribute_id = " . $this->attributeId;
return $this->processQuery($query);
} }
public function insertAttribute($inputModel) public function insertAttribute($inputModel)
@ -64,12 +67,18 @@ class AttributeModel extends Database {
"LOYALTY_VALUE": "http://localhost/CustomerRewardsRESTAPI/public/images/1.jpg" "LOYALTY_VALUE": "http://localhost/CustomerRewardsRESTAPI/public/images/1.jpg"
} }
*/ */
$keys = array_keys($jsonPayLoad); $keys = array_keys($jsonPayLoad);
$n = count($keys); $n = count($keys);
$query .= "CALL update_member_attribute_proc (" . $jsonPayLoad[$keys[0]] . ", "; $query = "CALL update_loyalty_member_attribute_proc (" . $jsonPayLoad[$keys[0]] . ", ";
for($i = 1; $i < $n-1; $i++) { for($i = 1; $i < $n-1; $i++) {
$query .= "'" . $jsonPayLoad[$keys[$i]] . "', "; if($i == 3) {
$query .= $jsonPayLoad[$keys[$i]] . ", ";
}
else {
$query .= "'" . $jsonPayLoad[$keys[$i]] . "', ";
}
} }
$query .= $jsonPayLoad[$keys[$i]] . ")"; $query .= $jsonPayLoad[$keys[$i]] . ")";

View File

@ -69,7 +69,7 @@ class CustomerModel extends Database {
$query .= "'" . $jsonPayLoad[$keys[$i]] . "', "; $query .= "'" . $jsonPayLoad[$keys[$i]] . "', ";
} }
$query .= $jsonPayLoad[$keys[$i]] . ")"; $query .= $jsonPayLoad[$keys[$i]] . ")";
//return var_dump($query);
$rowCount = $this->processStatement($query); $rowCount = $this->processStatement($query);
return $rowCount; return $rowCount;
} }

View File

@ -100,7 +100,8 @@ class Database {
{ {
$response['status_code_header'] = 'HTTP/1.1 422 Unprocessable Query'; $response['status_code_header'] = 'HTTP/1.1 422 Unprocessable Query';
$response['body'] = json_encode([ $response['body'] = json_encode([
'error' => 'Invalid query' 'error' => 'Invalid query',
'message' => $msg
]); ]);
$this->strErrorDesc = 'Unprocessable Query'; $this->strErrorDesc = 'Unprocessable Query';
$this->strErrorHeader = 'HTTP/1.1 422 Unprocessable Query'; $this->strErrorHeader = 'HTTP/1.1 422 Unprocessable Query';