$stmt = $pdo->prepare('SELECT * FROM users'); $stmt->execute(); $results = $stmt->fetchAll(PDO::FETCH_ASSOC);
$query = "SELECT * FROM products"; $result = mysqli_query($conn, $query); $data = mysqli_fetch_all($result, MYSQLI_ASSOC);In this example, we are fetching all the rows of data from the "products" table using mysqli query. We are using the mysqli_fetch_all function to retrieve all the rows, and setting the result mode to MYSQLI_ASSOC to return an associative array. Package library: PHP MySQLi Extension Overall, the fetchAll method is a powerful tool for retrieving data from a database and is widely used in PHP applications. The package libraries used depend on the specific database driver being used (PDO or MySQLi).