PHP Snippet
PHP PDO Prepared Statements
Difficulty: Medium
Prepared statements protect you from SQL injection by separating the query template from the data. This snippet shows the canonical PDO pattern: connect, `prepare`, bind parameters by name, `execute`, and fetch. The runnable accordions use an in-memory SQLite database (`sqlite::memory:`) so the test wrapper does not need an external DB; the same code shape works against MySQL or PostgreSQL by changing the DSN.
