mirror of
https://github.com/sctn4elk/CustomerRewardsRESTAPI.git
synced 2025-01-09 15:14:29 -06:00
Continue work on insert
This commit is contained in:
parent
15d72de736
commit
e8698e360f
|
@ -119,13 +119,13 @@ class CustomerController extends BaseController{
|
|||
// reads the raw POST data and returns it as a string.
|
||||
$jsonPayload = file_get_contents('php://input');
|
||||
$input = json_decode($jsonPayload, TRUE);
|
||||
//if (! $this->validatePerson($input)) {
|
||||
//return $this->unprocessableEntityResponse();
|
||||
//}
|
||||
return var_dump($input);
|
||||
if (! $this->validatePerson($input)) {
|
||||
return $this->unprocessableEntityResponse();
|
||||
}
|
||||
//return var_dump($input);
|
||||
//remove customer_id field so it doesn't break
|
||||
unset($input['customer_id']);
|
||||
return var_dump($input);
|
||||
//return var_dump($input);
|
||||
//$modinput = json_encode($input);
|
||||
//$newinput = json_decode($modinput, TRUE);
|
||||
$response = $this->customerModel->insertCustomer($input);
|
||||
|
|
|
@ -86,18 +86,19 @@ class CustomerModel extends Database {
|
|||
return $this->processQuery("SELECT * FROM customer_view WHERE customer_id = ?", ["i", $this->customerId]);
|
||||
}
|
||||
|
||||
public function insertCustomer($jsonPayLoad)
|
||||
public function insertCustomer($inputModel)
|
||||
{
|
||||
//return var_dump($jsonPayLoad);
|
||||
$keys = array_keys($jsonPayLoad);
|
||||
$keys = array_keys($inputModel);
|
||||
$n = count($keys);
|
||||
|
||||
$query .= "CALL insert_new_customer_proc ('" . $jsonPayLoad[$keys[0]] . "', ";
|
||||
for($i = 1; $i < $n-1; $i++) {
|
||||
$query .= "'" . $jsonPayLoad[$keys[$i]] . "', ";
|
||||
$query .= "CALL insert_new_customer_proc (";
|
||||
for($i = 0; $i < $n-1; $i++) {
|
||||
$query .= "'" . $inputModel[$keys[$i]] . "', ";
|
||||
}
|
||||
$query .= $jsonPayLoad[$keys[$i]] . ")";
|
||||
return var_dump($query);
|
||||
$query .= $inputModel[$keys[$i]] . ")";
|
||||
//return var_dump($query);
|
||||
|
||||
$rowCount = $this->processStatement($query);
|
||||
return $rowCount;
|
||||
}
|
||||
|
|
|
@ -65,10 +65,10 @@ class Database {
|
|||
if($stmt === false) {
|
||||
throw New Exception("Unable to prepare the statement: " . $query);
|
||||
}
|
||||
|
||||
//return var_dump($query);
|
||||
$result = $stmt->execute();
|
||||
if($result === false) {
|
||||
throw New Exception("Unable to execute the statement.");
|
||||
throw New Exception("Unable to execute the statement: " . $query);
|
||||
}
|
||||
|
||||
//$rowCount = $this->executeStatement($stmt);
|
||||
|
|
Loading…
Reference in New Issue
Block a user