Пример #1
0
 function GetAll()
 {
     global $sqldb;
     $testAutoren = array();
     for ($i = 0; $i < 3; $i++) {
         $autor = new stdClass();
         $autor->Nr = $i;
         $autor->Name = "Autor {$i}";
         $testAutoren[] = $autor;
     }
     $sqldb->ExpectQuery('', $testAutoren);
     $resultAutoren = Autor::GetAll(123);
     $result = $sqldb->Verify();
     if ($result !== true) {
         $result->Unit = "Autor";
         $result->Test = "GetAll";
         return $result;
     }
     for ($i = 0; $i < 3; $i++) {
         if ($testAutoren[$i]->Nr != $resultAutoren[$i]->Nr) {
             return new ErrorMessage("Autor", "GetAll", "Nummer von Autor {$i} falsch", $testAutoren[$i]->Nr, $resultAutoren[$i]->Nr);
         }
         if ($testAutoren[$i]->Name != $resultAutoren[$i]->Name) {
             return new ErrorMessage("Autor", "GetAll", "Name von Autor {$i} falsch", $testAutoren[$i]->Name, $resultAutoren[$i]->Name);
         }
     }
     return true;
 }
Пример #2
0
 function Literatur($nr)
 {
     global $db_config, $sqldb;
     // Suche Literatur mit Literatur_Nr = $nr heraus
     $sql = "SELECT Literatur_Nr, Art, Titel, Jahr, Verlag, ISBN, Beschreibung, Ort, Stichworte\n\t\t\t\t\tFROM " . $db_config['prefix'] . "Bibliothek\n\t\t\t\t\tWHERE Literatur_Nr='{$nr}'\n\t\t\t\t\tLIMIT 1";
     $sqldb->Query($sql);
     // Lese gefundene Daten aus
     if ($cur = $sqldb->Fetch()) {
         $this->Nr = $cur->Literatur_Nr;
         $this->Art = new LiteraturArt($cur->Art);
         $this->Titel = $cur->Titel;
         $this->Jahr = $cur->Jahr;
         $this->Verlag = $cur->Verlag;
         $this->ISBN = $cur->ISBN;
         $this->Beschreibung = $cur->Beschreibung;
         $this->Ort = $cur->Ort;
         $this->Stichworte = $cur->Stichworte;
         $this->Autoren = Autor::GetAll($nr);
         $this->Kommentare = Kommentar::GetAll($nr);
     }
 }
Пример #3
0
 function AutorTitelSuche($titel, $autor)
 {
     global $sqldb, $db_config;
     $this->Treffer = array();
     $titel = trim($titel);
     $autor = trim($autor);
     if (empty($titel) === false || empty($autor) === false) {
         // Finde Literatur mit Titel und Autor
         $sql = "SELECT DISTINCT bibliothek.Literatur_Nr AS Nr, Titel, Verlag, ISBN\n\t\t\t\t\t\tFROM (" . $db_config['prefix'] . "Bibliothek AS bibliothek\n\t\t\t\t\t\t\tINNER JOIN  " . $db_config['prefix'] . "Literatur_Autor AS connect\n\t\t\t\t\t\t\tON bibliothek.Literatur_Nr = connect.Literatur_Nr)\n\t\t\t\t\t\tINNER JOIN  " . $db_config['prefix'] . "Autoren AS autoren\n\t\t\t\t\t\tON connect.Autor_Nr = autoren.Autor_Nr\n\t\t\t\t\t\tWHERE bibliothek.Titel like '%" . $titel . "%'";
         // Trenne kommagetrennte Autorenliste und
         // füge es Suche hinzu
         if (empty($autor) === false) {
             $sql .= " AND (";
             $authors = array();
             $authors = split(",", $autor);
             for ($i = 0; $i < count($authors); $i++) {
                 if ($i != 0) {
                     $sql .= " OR ";
                 }
                 $sql .= "autoren.Autorname like '%" . trim($authors[$i]) . "%'";
             }
             $sql .= ")";
         }
         $sqldb->Query($sql);
         // Lese Treffer aus
         while ($cur = $sqldb->Fetch()) {
             $this->Treffer[] = $cur;
         }
         // Lese zu jedem Treffer Autoren
         for ($i = 0; $i < count($this->Treffer); $i++) {
             // Kommagetrennte Autorenliste erstellen
             $authors = Autor::GetAll($this->Treffer[$i]->Nr);
             // Erstelle kommagetrennte Liste der Autoren
             $autorlist = "";
             if (empty($authors) === false) {
                 $autornamen = array();
                 foreach ($authors as $cur) {
                     $autornamen[] = $cur->Name;
                 }
                 $autorlist = implode(", ", $autornamen);
             }
             $this->Treffer[$i]->Autor = $autorlist;
         }
     }
 }