params[$name] = $value; } /* * @assert ('name') == 'value' */ public function __get($name) { //echo "Getting '$name'\n"; if (array_key_exists($name, $this->params)) { return $this->params[$name]; } $trace = debug_backtrace(); trigger_error( 'Undefined property via __get(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE); return null; } /* * @assert ('name') == 'true' * @assert ('test') == 'false' */ public function __isset($name) { //echo "Is '$name' set?\n"; return isset($this->params[$name]); } public function __unset($name) { //echo "Unsetting '$name'\n"; unset($this->params[$name]); } public function findAllCustomers() { return $this->processQuery("SELECT * FROM customer_view ORDER BY customer_id ASC LIMIT ?", ["i", $this->limit]); } public function findByCustomerId() { return $this->processQuery("SELECT * FROM customer_view WHERE customer_id = ?", ["i", $this->customerId]); } public function insertCustomer($inputModel) { //return var_dump($jsonPayLoad); $keys = array_keys($inputModel); $n = count($keys); $query .= "CALL insert_new_customer_proc ("; for($i = 0; $i < $n-1; $i++) { $query .= "'" . $inputModel[$keys[$i]] . "', "; } $query .= $inputModel[$keys[$i]] . ")"; //return var_dump($query); $rowCount = $this->processStatement($query); return $rowCount; } public function updateCustomer($jsonPayLoad) { $keys = array_keys($jsonPayLoad); $n = count($keys); $query .= "CALL update_existing_customer_proc (" . $jsonPayLoad[$keys[0]] . ", "; for($i = 1; $i < $n-1; $i++) { $query .= "'" . $jsonPayLoad[$keys[$i]] . "', "; } $query .= $jsonPayLoad[$keys[$i]] . ")"; $rowCount = $this->processStatement($query); //$result = (object) ['rowCount'=>$rowCount]; return $rowCount; } public function deleteCustomer() { $rowCount = $this->processStatement("DELETE FROM customer WHERE customer_id = ?", [$this->customerId]); $result = (object) ['rowCount'=>$rowCount]; return $result; } }