General Report

Learn how to use the SQL “INNER JOIN” clause to query data from a number of tables.

We'll cover the following...

We need to get all the information about the tasks with totals from the database. For this, we’ll create the reports.php file in both the controllers and the views folders.

Model

In our model.php file, we’ll need to modify the get_all_tasks() function. Don’t forget that the tasks and projects tables are in a relationship. Therefore, we also need a way to select corresponding projects along with the tasks. One way to do this is by using the SQL INNER JOIN clause.

We’ll replace the $sql = 'SELECT * FROM tasks ORDER BY ...