Lesson content
Read, practise, then check your understanding
CRUD means create, read, update, and delete. HTTP and database operations should validate identifiers, authorize the acting user, parameterize values, and return stable outcomes.
Practical example
<?php
$stmt = $pdo->prepare('UPDATE users SET name = :name WHERE id = :id');
$stmt->execute(['name' => $name, 'id' => $id]);
if ($stmt->rowCount() === 0) { /* distinguish unchanged or missing deliberately */ }
Use transactions for related changes and optimistic locking/version columns for concurrent edits. Paginate large reads with stable ordering. Decide between hard delete, soft delete, and archival based on domain/legal needs. Audit sensitive changes.
Knowledge check
Answer every question correctly to complete this chapter.
0 of 10 checks passed
Your progress is saved on this device.