During this week i have gained a lot of new skills in integrating PHP with Databases. The reason for this has primarily been that my goal for this week is to turn the static media library into a dynamic media library and this is only possible through an SQL Database.
Building a PHP-Driven webpage is the first step in mastering PHP which i did last week. I have been told that the true power of PHP shines when you connect it to a data source like an API or a Database. I already have made the Personal Media Library application and i will refactor this by replacing an associative array with a database to provide a more robust and scalable tool to store the data in the media library.
Through out the process my goal is to learn how to use PDO — extensions to communicate with databases. I already know about relational databases including how to search and join data across multiple tables.
This week i will learn
- Databases (Advanced)
- Error Handling
- Search (SQL using SQLite)
- Refactoring (turning the static into dynamic)
The 5 days
Monday – PHP and Databases
Refactoring the existing project to use a database. Then i leveraged the use of this database fo pagination and search capabilities on the site.
Tuesday – Querying the Database with PHP
Yesterday i learned about how connection to a database and how i can use it to retrieve data for my project. Today i will do more database work and see how i can run a select, retrieve the results and integrate them into the media library.
Wednesday – Using Relational Tables
Using my knowledge from earlier about relation databases. Today is going to be about how to use the relationships in my database to JOIN data from multiple tables. I will also be using the PHP Data Object to address security concerns for this and future projects.
Thursday – Limiting Records in SQL
Today is gonna be about modifying my functions to use their own SQL queries to retrieve onle the items i need in the first place. It’s not a big issue in this project, but image working with thousands of items and you only need four items and the query return 100.000 items.. I will also look at different ways of how to use SQL-specific features like limits, ordering and aggregate functions to fine tune the query for the individual page.
Friday – Filtering Input for Queries
Today will be about search!! The site needs a search function and this will be added today. In my opinion it’s a very important feature, and i would like to add this functionality to every page i come across! I already separated the project into different files and thank god for that – because of this i only need to do the implementation in one place. This will only require med to do a little modification on the catalog page, so i easily can use the same code to display results.