Book Image

CodeIgniter Web Application Blueprints

Book Image

CodeIgniter Web Application Blueprints

Overview of this book

Table of Contents (16 chapters)
CodeIgniter Web Application Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating the model


There is only one model in this project—shop_model.php—which contains functions that are specific to searching and writing products to the database.

This is our one and only model for this project; let's briefly go over each function in it to give us a general idea of what it does, and then we will go into more detail in the code.

There are five main functions in this model, which are as follows:

  • get_product_details(): This accepts one argument—the $product_id—of the product being added to the cart and returns a database result object that contains information about a specific product. This model function is used by the shop controller's add() function to fetch the correct details about a product before it is added to the cart.

  • get_all_products(): This accepts no argument. This model function will return a list of products (as defined in the products table) to the shop controller's index() function.

  • get_all_products_by_category_name(): This accepts one argument—$cat_url_name...