$pdo = new PDO('mysql:host=localhost;dbname=blog', 'username', 'password'); $statement = $pdo->query('SELECT * FROM articles'); $articles = $statement->fetchAll(PDO::FETCH_ASSOC);
$category = 'Technology'; $pdo = new PDO('mysql:host=localhost;dbname=blog', 'username', 'password'); $statement = $pdo->prepare('SELECT * FROM articles WHERE category = :category'); $statement->bindValue(':category', $category); $statement->execute(); $articles = $statement->fetchAll(PDO::FETCH_ASSOC);Package Library: PDO is a database library that is used in these examples. It is part of the PHP core and does not require any external package.