コード例 #1
0
ファイル: boekDAO.php プロジェクト: j4chal/ooOefening
 /**
  * @param1 is the book I want to save
  * @return the saved object
  **/
 public function save(Boek $book)
 {
     $properties = $book->giveAllPropertiesArray();
     // gets all the properties in the form of a array
     foreach ($properties as $key => $value) {
         $this->valtodata($key, $value);
     }
     $id = $book->id;
     if ($book->id == 0) {
         $retid = OpslagMedium::storeObject($this::tablename, $properties);
     } else {
         $retid = OpslagMedium::updateObject($this::tablename, $book->id, $book->changedProperties);
     }
     if ($retid != 0) {
         $query = $this->getDatafieldname('id') . '=' . $retid . ' ';
         $this->convertdata(OpslagMedium::getObjectdataOnQuery($this::tablename, $query));
         $retobj->result = true;
         return $this->GetBookObject();
     }
 }
コード例 #2
0
ファイル: ObjFact_Book.php プロジェクト: j4chal/ooOefening
 /**
  * Creates an object of the form book from the dao data object
  * 
  * @param1  data object as formed by the dao
  * 
  */
 public function create($data)
 {
     $object = new Boek();
     $object->id = $data->id;
     $object->setIsbn($data->isbnnr);
     $object->setPrice($data->prijs);
     $object->setTitel($data->titel);
     $object->setUitgever($data->uitgever);
     $object->setAuteur($data->auteur);
     $object->InitChanged();
     /// resets the changed table which is influeced by the above settings
     return $object;
 }
コード例 #3
0
 public static function create($titel, $genreId)
 {
     $bestaandBoek = self::getByTitel($titel);
     if (isset($bestaandBoek)) {
         throw new TitelBestaatException();
     }
     $sql = "INSERT INTO mvc_boeken (titel, genreid) VALUES ('" . $titel . "', " . $genreId . ")";
     $dbh = new PDO(DBConfig::$DB_CONNSTRING, DBConfig::$DB_USERNAME, DBConfig::$DB_PASSWORD);
     $dbh->exec($sql);
     $boekId = $dbh->lastInsertId();
     $dbh = NULL;
     $genre = GenreDAO::getById($genreId);
     $boek = Boek::create($boekId, $titel, $genre);
     return boek;
 }
コード例 #4
0
ファイル: BoekDAO.php プロジェクト: Annemieps/oefenproject
 public function create($titel, $genreId)
 {
     $dbh = new PDO(DBConfig::$DB_CONNSTRING, DBConfig::$DB_USERNAME, DBConfig::$DB_PASSWORD);
     $sql = "insert into mvc_boeken (titel, genre_id)  \n                    values (:titel, :genreId)";
     $stmt = $dbh->prepare($sql);
     $stmt->execute(array(':titel' => $titel, ':genreId' => $genreId));
     //id van de net ingevoerde boek
     $boekId = $dbh->lastInsertId();
     $dbh = null;
     //genre id ophalen voor het boek
     $genreDAO = new GenreDAO();
     $genre = $genreDAO->getById($genreId);
     //creer boek aan de hand van boekid,titel en genre
     $boek = Boek::create($boekId, $titel, $genre);
     return $boek;
 }
コード例 #5
0
 public function create($titel, $genreId)
 {
     $bestaandBoek = $this->getByTitel($titel);
     if (!is_null($bestaandBoek)) {
         throw new TitelBestaatException();
     }
     $sql = "insert into mvc_boeken (titel, genre_id) values (:titel, :genreId)";
     $dbh = new PDO(DBConfig::$DB_CONNSTRING, DBConfig::$DB_USERNAME, DBConfig::$DB_PASSWORD);
     $stmt = $dbh->prepare($sql);
     $stmt->execute(array(':titel' => $titel, ':genreId' => $genreId));
     $boekId = $dbh->lastInsertId();
     $dbh = null;
     $genreDAO = new GenreDAO();
     $genre = $genreDAO->getById($genreId);
     $boek = Boek::create($boekId, $titel, $genre);
     return $boek;
 }
コード例 #6
0
{
    public function getTitel()
    {
        $titel = "Handleiding HTML";
        return $titel;
    }
}
?>


<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <title>Boeken</title>
    </head>
    <body>
        <h1>
        <?php 
$boek = new Boek();
print $boek->getTitel();
?>
        </h1>
    </body>
</html>
コード例 #7
0
ファイル: BoekDAO.php プロジェクト: Annemieps/oefenproject
 public function getByTitel($titel)
 {
     $sql = "select mvc_boeken.id as boek_id, titel, genre_id, genre  \n\t\tfrom mvc_boeken, mvc_genres   \n\t\twhere genre_id = mvc_genres.id and titel = :titel";
     $dbh = new PDO(DBConfig::$DB_CONNSTRING, DBConfig::$DB_USERNAME, DBConfig::$DB_PASSWORD);
     $stmt = $dbh->prepare($sql);
     $stmt->execute(array(':titel' => $titel));
     $rij = $stmt->fetch(PDO::FETCH_ASSOC);
     if (!$rij) {
         return null;
     } else {
         $genre = Genre::create($rij["genre_id"], $rij["genre"]);
         $boek = Boek::create($rij["boek_id"], $rij["titel"], $genre);
         $dbh = null;
         return $boek;
     }
 }
コード例 #8
0
ファイル: TestObjecten.php プロジェクト: j4chal/ooOefening
<?php

// dit zijn de oude testen gemaakt voor de database layer
require_once '../config.php';
require_once $serverpath['objects'] . '/klant.php';
require_once $serverpath['objects'] . '/boek.php';
require_once $serverpath['objects'] . '/bestelling.php';
$klant = new Klant('*****@*****.**', 'password');
print_r($klant);
//$klant->setLeverAdres("trammezandlei 44 shoten");
echo "nieuwe klant: " . (string) $klant->getKlantId() . "<br>";
echo "adres klant: " . $klant->getLeverAdres() . "<br>";
// $boek10 = new Boek("test","12345",25,'test','uitgever');
$boek1 = new Boek('AJAX and PHP: Building Modern Web Applications 2nd Edition Paperback', '978-1847197726', 24, 'B Brinzarea-Iamani', 'pact publishing ltd');
$boek2 = new Boek('jQuery in Action, Second Edition', '978-1935182320', 15, 'Bear Bibeault', 'Manning publications');
$boek3 = new Boek('Mijn eigen testboek', '123-1234567', 55, 'krisg', 'kweetniet');
$klant->login('*****@*****.**', 'password');
//try to comment it to see the error
//$titel=$boek1->getTitel();
//echo $titel ;
echo "twee nieuwe boeken in stock;<br> boek 1 heeft als titel :" . $boek1->getTitel() . " en boek 2:" . $boek2->getTitel();
$bestelling = Nieuwebestelling($klant);
// $bestelling = new Bestelling($klant);
$bestelling->voegBoekToe($boek1);
print_r($bestlling);
// $bestelling->voegBoekToe($boek2);
alterbestelling($bestelling, $boek2, true);
// $bestelling->sluitOrderAf(); to test if I get the exception thrown
alterbestelling($bestelling, $boek3, true);
//$bestelling->printboeken();
echo "<h3> boeken uit bestelling :</h3>" . $bestelling->getBoeken();