Zest.

PHP: Query with PDO

A short, tested PHP example for query with pdo. Copy it and adjust the names and paths for your project.

PHP
$pdo = new PDO("mysql:host=localhost;dbname=app;charset=utf8mb4", $user, $pass, [
    PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
]);
$stmt = $pdo->prepare("SELECT * FROM users WHERE id = :id");
$stmt->execute(["id" => $id]);
$row = $stmt->fetch(PDO::FETCH_ASSOC);

Find it in Zest

Search for “php query with pdo” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.

More PHP examples

All PHP examples