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, tasks_model.php, that contains functions that are specific to searching and writing tasks 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_tasks(): This serves two functions: firstly, to display all tasks—for example, when a user first visits the site and when a user enters a new task in the form.

  • change_task_status(): This changes the tasks.task_status value in the database from either todo or done. A task that is set to done appears struck through in the list, whereas tasks that are set to todo are not struck through and are displayed normally; this way, a user can easily work out what is done and not done.

  • save_task(): This saves a task to the database when a user submits the form from point 3 (the Create item...