<?php
// Connect to the database
$dbh = new PDO("sqlite::memory:");
// A small piece of the "world" database
$dbh->exec("
CREATE TABLE countrylanguage (
CountryCode TEXT, Language TEXT, Percentage REAL)");
$dbh->exec("
INSERT INTO countrylanguage VALUES
('RUS', 'Russian', 86.6),
('RUS', 'Tatar', 3.2),
('RUS', 'Ukrainian', 0.3)");
// SQL query execution
$stmt = $dbh->prepare("
SELECT
Language, Percentage
FROM countrylanguage
WHERE
CountryCode = ? AND
Percentage > ?");
$stmt->execute(["RUS", 0.5]);
while ($row = $stmt->fetch(PDO::FETCH_LAZY)) {
echo $row['Language'] . ": " . $row['Percentage'], "\n";
}
$dbh = null;