mirror of
https://github.com/janunger/rheinwerk-video-training.git
synced 2026-02-05 22:55:14 +01:00
Kapitel 6 Lektion 7 gesplittet
This commit is contained in:
34
Kapitel_6/Lektion_8/mediathek_loesung/_application.php
Executable file
34
Kapitel_6/Lektion_8/mediathek_loesung/_application.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @return PDO
|
||||
*/
|
||||
function holeDatenbankverbindung()
|
||||
{
|
||||
return new PDO(
|
||||
'mysql:dbname=mediathek;host=localhost',
|
||||
'root',
|
||||
'root',
|
||||
[PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"]
|
||||
);
|
||||
}
|
||||
|
||||
function holeLied($liedId)
|
||||
{
|
||||
$db = holeDatenbankverbindung();
|
||||
$liedStatement = $db->prepare("
|
||||
SELECT
|
||||
lieder.track,
|
||||
lieder.titel,
|
||||
cds.id AS cd_id,
|
||||
cds.name AS cdname,
|
||||
kuenstler.name AS kuenstlername
|
||||
FROM lieder
|
||||
LEFT JOIN cds ON lieder.cd_id = cds.id
|
||||
LEFT JOIN kuenstler ON cds.kuenstler_id = kuenstler.id
|
||||
WHERE lieder.id = :lied_id
|
||||
");
|
||||
$liedStatement->execute(['lied_id' => $liedId]);
|
||||
|
||||
return $liedStatement->fetch(PDO::FETCH_ASSOC);
|
||||
}
|
||||
Reference in New Issue
Block a user