Beispiel #1
0
 public function run()
 {
     if (!isset($_POST["action"])) {
         return;
     }
     if ($_POST["action"] == "addComposer") {
         $composer = new composers();
         $composer->setComposerFirstname($_POST["ComposerFirstname"]);
         $composer->setComposerLastname($_POST["ComposerLastname"]);
         $composer->setDateOfBirth($_POST["DateOfBirth"]);
         $composer->setPlaceOfBirth($_POST["PlaceOfBirth"]);
         $composer->setBirthCountry($_POST["BirthCountry"]);
         $composer->setDeceased($_POST["Deceased"]);
         $composer->add();
     } elseif ($_POST["action"] == "updateComposer") {
         $composer = new composers();
         $composer->setComposerFirstname($_POST["ComposerFirstname"]);
         $composer->setComposerLastname($_POST["ComposerLastname"]);
         $composer->setDateOfBirth($_POST["DateOfBirth"]);
         $composer->setPlaceOfBirth($_POST["PlaceOfBirth"]);
         $composer->setBirthCountry($_POST["BirthCountry"]);
         $composer->setDeceased($_POST["Deceased"]);
         $composer->setID($_POST["id"]);
         $composer->update();
     } elseif ($_POST["action"] == "addSong") {
         $song = new Songs();
         $song->setComposersID($_POST["ComposersID"]);
         $song->setMusicalForm($_POST["MusicalForm"]);
         $song->setTitle($_POST["Title"]);
         $song->setOpus($_POST["Opus"]);
         $song->setMovement($_POST["Movement"]);
         $song->setLength($_POST["Length"]);
         $song->setDifficulty($_POST["Difficulty"]);
         $song->setWantToPlay($_POST["WantToPlay"]);
         $song->setConcertReady($_POST["ConcertReady"]);
         $song->add();
     } elseif ($_POST["action"] == "updateSong") {
         $song = new Songs();
         $song->setComposersID($_POST["ComposersID"]);
         $song->setMusicalForm($_POST["MusicalForm"]);
         $song->setTitle($_POST["Title"]);
         $song->setOpus($_POST["Opus"]);
         $song->setMovement($_POST["Movement"]);
         $song->setLength($_POST["Length"]);
         $song->setDifficulty($_POST["Difficulty"]);
         $song->setWantToPlay($_POST["WantToPlay"]);
         $song->setConcertReady($_POST["ConcertReady"]);
         $song->setID($_POST["id"]);
         $song->update();
     }
 }
Beispiel #2
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 'on');
echo "<pre>";
$config = parse_ini_file('config.ini');
require_once 'lib/Model/composers.php';
require_once 'lib/Model/songs.php';
require_once 'lib/Model/musicalForms.php';
$song = new Songs();
$song->setTitle('blaat');
$song->setMusicalForm(1);
$song->setLength('10:00:00');
$song->setDifficulty(5);
$song->setWantToPlay(2);
$song->setConcertReady(2);
$song->add();
/*
// Quick and dirty demo how to use object array in a view
$songs = new Songs;
foreach($songs->fetch() as $song){
    echo "<table>";
    echo "<tr>";
    echo "<td>";
    echo $song->getId();
    echo "</td>";
    echo "<td>";
    echo $song->getTitle();
    echo "</td>";
    echo "</tr>";
    echo "</table>";
Beispiel #3
0
 /**
  * Fetch all from Songs DB and set all fetched data to parameters
  */
 public function fetch()
 {
     $sql = 'SELECT * FROM Songs';
     $songs = [];
     foreach ($this->con->query($sql) as $row) {
         $song = new Songs();
         $song->setID($row['ID']);
         $song->setComposersID($row['ComposersID']);
         $song->setMusicalForm($row['MusicalForm']);
         $song->setTitle($row['Title']);
         $song->setOpus($row['Opus']);
         $song->setMovement($row['Movement']);
         $song->setLength($row['Length']);
         $song->setDifficulty($row['Difficulty']);
         $song->setWantToPlay($row['WantToPlay']);
         $song->setConcertReady($row['ConcertReady']);
         $songs[] = $song;
     }
     return $songs;
 }