A database stores your information permanently: users, articles, orders and so on. PHP most often talks to MySQL.
The basic vocabulary
- Database: the big container.
- Table: a grid of data (e.g. users).
- Column: a field (e.g. name, email).
- Row: a single record (one specific user).
Talking to it from PHP
You use the modern PDO extension (or mysqli). The main steps:
- Connect to the database with the host, the name, the user and the password.
- Write an SQL query, for example SELECT * FROM users.
- Run the query and loop through the results.
The query language is called SQL: SELECT to read, INSERT to add, UPDATE to change, DELETE to remove.
Key point: a database holds tables, made of columns and rows. PHP connects to it through PDO and communicates in SQL.