Backend development

Stage 2 · Lesson 9 of 10

PDO, Eloquent and migrations

Relational databases and SQL

Start with PDO, PHP's built-in database layer. You write a with , run it with your values and fetch the rows. That shows you exactly what does for you later.

Eloquent is 's ORM. Each model maps to a table. Relationships are methods such as hasMany and belongsTo.

Queries read like Order::where('status', 'paid')->latest()->get(). Schema changes live in classes. You create them with php artisan make:migration and apply them with php artisan migrate, which records what has run. Guard against mass assignment (users setting fields they should not) with $fillable.

Common trapediting an old migration after it has run in production, or running php artisan migrate:fresh anywhere near real data, since it drops every table.

A question to check yourself, an AI practice session and 3 cheat sheet entries come with the full roadmap. Unlock

Resources for this stage

Start with· follow one of these

Practise

Also worth your time

Mark this stage as not done?