diff --git a/Controller/API/CustomerController.php b/Controller/API/CustomerController.php index 2825425..fc0fab5 100644 --- a/Controller/API/CustomerController.php +++ b/Controller/API/CustomerController.php @@ -1,6 +1,6 @@ strErrorDesc = ''; $this->strErrorHeader = ''; - try { - $this->customerModel = new CustomerModel(); - $this->requestMethod = $this->getServerRequestMethod(); + try { + $this->requestMethod = $this->getServerRequestMethod(); + //return var_dump($this->requestMethod); switch($this->action) { case "select": $response = $this->selectAction(); @@ -77,14 +77,18 @@ class CustomerController extends BaseController { return; } + require_once PROJECT_ROOT_PATH . "/Model/CustomerModel.php"; + $this->customerModel = new CustomerModel(); + //return var_dump($this->customerModel); $this->arrQueryStringParams = $this->getQueryStringParams(); + if (isset($this->arrQueryStringParams['customer_id'])) { $response = $this->selectByIdAction(); } else { - $this->customerModel->limit = 10; + //$this->customerModel->limit = 10; if (isset($this->arrQueryStringParams['limit'])) { - $customerModel->limit = $this->arrQueryStringParams['limit']; + $this->customerModel->limit = $this->arrQueryStringParams['limit']; } $response = $this->customerModel->findAllCustomers(); unset($this->customerModel->limit); diff --git a/Include/bootstrap.php b/Include/bootstrap.php index 45bbd41..c70be54 100644 --- a/Include/bootstrap.php +++ b/Include/bootstrap.php @@ -11,7 +11,7 @@ require_once PROJECT_ROOT_PATH . "/include/config.php"; // include the base controller file require_once PROJECT_ROOT_PATH . "/Controller/Api/BaseController.php"; // include the use model file -require_once PROJECT_ROOT_PATH . "/Model/CustomerModel.php"; -require_once PROJECT_ROOT_PATH . "/Model/ImageModel.php"; +//require_once PROJECT_ROOT_PATH . "/Model/CustomerModel.php"; +//require_once PROJECT_ROOT_PATH . "/Model/ImageModel.php"; // include the tests autoloader when in development //require_once __DIR__ . '/../vendor/autoload.php'; diff --git a/Model/CustomerModel.php b/Model/CustomerModel.php index 97a3e8e..5c2e028 100644 --- a/Model/CustomerModel.php +++ b/Model/CustomerModel.php @@ -1,10 +1,4 @@ connection = new mysqli(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_DATABASE_NAME); - + if ( mysqli_connect_errno()) { throw new Exception("Could not connect to database."); } diff --git a/index.php b/index.php index b80eb17..1c6af53 100644 --- a/index.php +++ b/index.php @@ -36,7 +36,7 @@ if (!isset($uri[$uri_pos]) || !isset($uri[$uri_pos+1]) || !isset($uri[$uri_pos+2 header("HTTP/1.1 404 Not Found"); exit(); } - +//echo var_dump($uri); switch($uri[$uri_pos + 1]) { case "purchase": header("HTTP/1.1 404 Module Not Defined");