Exploring the Code
Exploring the Code
SHUBHAM MUNGARA
3) The content of the displayed page depends on two important parameters: target and function. What
are the default values of these parameters (without clicking on the links on the home page)?
When no parameters are passed to the page in the URL (e.g., visiting the site at /index.php without query
strings), the system will display the Home page of the users target by using the home function. This results
in: • The view displayed: views/home.php • The title of the page: "Home page".
4) Which files are used to display the first page (containing the html code used to code the visuals on
this page)?
5) In which folder is the file that calls these visual pages located?
6) Does the display of the homepage involve files from the folder?
Yes, files from the controller folder are involved in the homepage will display.
7) From the home page, click on the link that displays the list of users. From the URL on the browser,
indicate the value of the target and function variables.
http://localhost/Example-MVC-ADVANCED/index.php?target=users&function=list
9) Find the function that retrieves the list of users and give its name.
function getAllUsers
10) Identify the SQL query in the code for this function. Describe this query.
function getAllUsers(PDO $db): array { $query = 'SELECT * FROM users'; This function selects all the values
in the table users and displays them
Understanding Example MVC-ADVANCED
SHUBHAM MUNGARA
Models/requests.users.php
The controllers folder contains files, like users.php, that call the getUsers() function.
13) To retrieve the list of users from the database, you first need to connect to the database. In this
phase we specify the url to the server that contains the database, the database name, and the
connection parameters: login and password. Find the part of the code that provides this connection
before executing the request.
14) Propose a summary diagram illustrating the steps involved in displaying the list of users, specifying
the order of the files involved and highlighting the MVC (Model-View-Controller) design pattern.