24 lines
714 B
PHP
24 lines
714 B
PHP
<?php
|
|
|
|
namespace Blog\Model;
|
|
|
|
use Blog\Model\Database;
|
|
use PDOException;
|
|
use Random\RandomException;
|
|
|
|
class CourseModel extends Database
|
|
{
|
|
public function getCourseById(string $id){
|
|
$pdo = $this->linkDB();
|
|
$sql = "SELECT k.id, k.name, k.preis, k.dauer, k.rabatt, k.kategorie, k.beschreibung, k.ort_id,
|
|
o.stadt, o.strasse, o.plz, b.note, b.kommentar
|
|
FROM kurs k
|
|
JOIN ort o ON k.ort_id = o.id
|
|
LEFT JOIN bewertungen AS b ON b.kurs_id = k.id
|
|
WHERE k.id = :id";
|
|
$sth = $pdo->prepare($sql);
|
|
$sth->execute([':id' => $id]);
|
|
$result = $sth->fetch(\PDO::FETCH_ASSOC);
|
|
return $result ?? null;
|
|
}
|
|
} |