TheMathWizard/index.php
2022-12-16 10:37:54 +01:00

19 lines
No EOL
623 B
PHP

<?php
require 'functions.php';
require 'Database.php';
require 'router.php';
$username = 'appUser';
$password = 'password';
$config = require('config.php');
$db = new Database($config['database'], $username, $password);
$id = $_GET['id'];
// Variante 1
$query = "SELECT * FROM posts WHERE id = ?";
$posts = $db->query($query, [$id])->fetchAll(PDO::FETCH_ASSOC);
// Variante 2
//$query = "SELECT * FROM posts WHERE id = :id";
//$posts = $db->query($query, [':id' => $id])->fetchAll(PDO::FETCH_ASSOC);
// Beide Varianten machen inhaltlich das Gleiche.
// freie Wahl, welche der beiden Varianten bevorzugt wird.
//dd($posts);