';
print_r(pdo_drivers());
echo '
';
include 'adatok.php';
echo "
";
echo "Id | Firstname | Lastname |
";
class TableRows extends RecursiveIteratorIterator {
function __construct($it) {
parent::__construct($it, self::LEAVES_ONLY);
}
function current() {
return "" . parent::current(). " | ";
}
function beginChildren() {
echo "";
}
function endChildren() {
echo "
" . "\n";
}
}
try {
$conn = new PDO("pgsql:host=$host;port=$port;dbname=$adatbazis", $user, $jelszo);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("SELECT id, firstname, lastname FROM MyGuests");
$stmt->execute();
// set the resulting array to associative
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
foreach(new TableRows(new RecursiveArrayIterator($stmt->fetchAll())) as $k=>$v) {
echo $v;
}
}
catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}
$conn = null;
echo "
";
?>