<?php


//Variablen für Datenbankverbindung
include("list.php");



// Aufbau der Datenbankverbindung
try {
    $pdo = new PDO("mysql:dbhost=$dbhost;dbname=$dbname;charset=utf8", $dbuser, $dbpw);
} catch (PDOException $e) {
    die ($e->getMessage());
}

//Die SQL Anweisung wird in eine Variable gepackt
$sql = "SELECT * FROM teilnehmer LIMIT 5";


if($stmt = $pdo->query($sql)) {

    echo "<h2>PDO::FETCH_ASSOC</h2>";
    $a = $stmt->fetch(PDO::FETCH_ASSOC);
    echo "<pre>", print_r($a) ,"</pre>";

    echo "<h2>PDO::FETCH_NUM</h2>";
    $a = $stmt->fetch(PDO::FETCH_NUM);
    echo "<pre>", print_r($a) ,"</pre>";

    echo "<h2>PDO::FETCH_BOTH</h2>";
    $a = $stmt->fetch(PDO::FETCH_BOTH);
    echo "<pre>", print_r($a) ,"</pre>";

    echo "<h2>PDO::FETCH_OBJ</h2>";
    $a = $stmt->fetch(PDO::FETCH_OBJ);
    echo "<pre>", print_r($a) ,"</pre>";

    echo "<h2>PDO::FETCH_LAZY</h2>";
    $a = $stmt->fetch(PDO::FETCH_LAZY);
    echo "<pre>", print_r($a) ,"</pre>";
}

?>