In this example, we will demonstrate business logic. Ordering a product will trigger the model to update the product's quantity and check whether it's smaller than a certain amount.
This example will be constructed from the following controllers, model, and view:
application/controllers/order.php
: This controller loads the modelproductmodel
$this->load->model(' productmodel')
: This controller renders the vieworderview
, which displays all the products, and where each product has links to ordering a productapplication/models/productmodel.php
: This model contains functions, which retrieve products, updates its quantity, and checks its quantityapplication/views/ orderview.php
: The view displays all the products in a table, where each row has a link for ordering the product
Let us assume the URI to the project root is http://mydomain.com/myproject
and http://mydomain.com/myproject/order
.