The purpose of this lab is to set up Laragon, get hands-on experience with MySQL commands, and create your first database and table.
-
Install and Configure Laragon
Set up Laragon and ensure it is properly configured. Access MySQL through the Laragon terminal to get started. -
Explore Basic MySQL Commands
Learn essential MySQL commands, such as creating a database, selecting a database for use, and creating tables. -
Insert Data into Tables
Practice adding data to your table using theINSERT
command. -
Retrieve Data with Queries
Use theSELECT
command to query and view data. Practice retrieving all records from a table. -
Understand Primary Keys and Timestamps
Learn the importance of primary keys in uniquely identifying records and understand how timestamps are used in tables.
For this lab, I used MySQL Workbench instead of phpMyAdmin. Since MySQL is already installed on my device, I find MySQL Workbench easier and more efficient to use.
Fig: Basic MySQL commands practiced during the lab.
Enhance your ability to write effective SQL queries and solve real-world problems using MySQL.
-
Filter Data with Conditions
Practice retrieving specific rows using theWHERE
clause based on criteria such as ID, name, or date. -
Sort and Group Data
Explore theORDER BY
clause for sorting data andGROUP BY
for grouping results. -
Solve Query Challenges
- Fetch records that match specific conditions (e.g., emails containing a certain domain name).
- Count the total rows in a table or calculate the average of a column.
-
Work with Aggregate Functions
Practice using aggregate functions likeSUM
,COUNT
, andMAX
to manipulate and analyze data. -
Document Queries and Results
Keep a record of each query you run and the corresponding results to better understand how they work.
Gain an understanding of the Model-View-Controller (MVC) architecture and its role in web development.
-
Understand MVC Components
- Model: Manages data and database interactions.
- View: Responsible for displaying information to users (HTML/CSS).
- Controller: Serves as a link between the Model and View, handling the application logic.
-
Set Up MVC Project Structure
Create folders formodels
,views
, andcontrollers
to organize your code. -
Build a Simple Example
- Model: Create a component to fetch mock data.
- Controller: Write logic to process the request and pass data to the view.
- View: Display the fetched data to the user.
Learn how to connect a PHP application to a MySQL database using either MySQLi or PDO.
-
Understand MySQLi and PDO
Compare MySQLi and PDO, and learn when to use each based on the project requirements. -
Write Connection Code
Develop a basic connection script that includes error handling for database connectivity. -
Test Database Connectivity
Create a simple PHP script to check if the database connection is successful. -
Secure Credentials
Learn techniques to securely store and manage database credentials.
Implement the Create functionality in PHP to insert data into the MySQL database.
-
Capture and Validate Form Data
Use PHP to collect form inputs and validate the data (e.g., ensure no fields are left empty). -
Test Data Insertion
Test the form to ensure the data is correctly inserted into the database.
Learn how to modify and remove records from the database using PHP.
-
Update Existing Records
- Create a form to update records.
- Use a hidden input field to pass the unique identifier (e.g., ID) of the record.
- Validate the data before executing the update operation.
-
Delete Records
- Add a Delete button or link for removing records.
- Implement confirmation dialogs to prevent unintentional deletions.
-
Test Update and Delete Operations
Verify the changes in the database to ensure the operations were successful.