PHP Code Reorder Medium +20 XP
PDO Query
Arrange the PDO prepared statement correctly.
Click lines in the correct order
Available lines4 left
Your order
Click lines above to build your solution.
Show answer and explanation
Answer: $pdo = new PDO($dsn, $user, $pass);
$stmt = $pdo->prepare("SELECT * FROM users WHERE id = ?");
$stmt->execute([$id]);
$result = $stmt->fetchAll();
Create connection, prepare statement, execute with params, then fetch results.
Hint: Connect before you can query.
What this challenge tests
Code Reorder in PHP: pdo, prepared-statements.