$stmt = $pdo->prepare("SELECT * FROM users"); $stmt->execute(); $results = $stmt->fetchAll();
$stmt = $pdo->prepare("SELECT * FROM users WHERE age > ?"); $stmt->execute([$ageLimit]); $results = $stmt->fetchAll();In this example, we prepare a SQL statement to select all rows from the "users" table where the age is greater than a given limit. We pass in the limit as a parameter when we execute the statement, and we fetch all the results using the fetchAll function. The PHP self fetchAll function is part of the PDO (PHP Data Objects) library, which provides a consistent interface for accessing databases in PHP.