diff --git a/db.sqlite b/db.sqlite new file mode 100644 index 0000000..d65213f Binary files /dev/null and b/db.sqlite differ diff --git a/index.php b/index.php new file mode 100644 index 0000000..4c2ceb1 --- /dev/null +++ b/index.php @@ -0,0 +1,55 @@ +prepare( + 'INSERT INTO allergies ("label", "from", "to") VALUES (:label, :from, :to)'); +$query->execute([ + 'label' => 'Peanuts', + 'from' => strtotime('2025-01-01'), + 'to' => strtotime('2025-12-31'), +]); + +// last inserted id +$lastId = $pdo->lastInsertId(); +echo 'Last inserted id: ' . $lastId; + +// R = READ +// select data from table +$query = $pdo->prepare('SELECT * FROM allergies'); +$query->execute(); +$allergies = $query->fetchAll(PDO::FETCH_ASSOC); + +echo "
" . $allergy['id'] . " | "; + echo "" . $allergy['label'] . " | "; + echo "" . date('d.m. Y', $allergy['from']) . " | "; + echo "" . date('d.m. Y', $allergy['to']) . " | "; + echo "