public function getAllAsObject($restriction = '') { $sql = "SELECT *\n\t\t\t\tFROM schueler\n\t\t\t\tWHERE 1=1"; $sql .= $restriction . ";"; try { $result = mysql_query($sql); if (!result) { throw new MysqlException(); } $schuelers = array(); while ($row = mysql_fetch_assoc($result)) { $s = new Schueler(); $s->setId($row['schueler_id']); $s->setVorname($row['vorname']); $s->setNachname($row['nachname']); $s->setKlasse_id($row['klasse_id']); $schuelers[$s->getId()] = $s; } } catch (MysqlException $e) { Html::showAll($e); } return $schuelers; }
/** * lŠdt in schuelers die SchŸler, * die zu dieser /Schul-) klasse gehšren * */ public function loadSchuelers() { $s = new Schueler(); $this->schuelers = $s->getAllAsObject(' AND klasse_id = ' . $this->klasse_id . ' '); }
<?php $s = new Schueler(); $schuelers = $s->getAllAsObject(); foreach ($schuelers as $key => $schueler) { $schuelers[1]->loadNotens(); } $htmls = new HtmlSchueler($schuelers); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Notenliste</title> <link type="text/css" href="Style.css" rel="stylesheet" /> <script type="text/javascript" src="Script.js"></script> </head> <body> <h2>Notenliste</h2> <br><br> <form name="notenform" method="post" action=""> <table class="scrollTable" id="scrollTable" cellpadding="0" cellspacing="0" border="0"> <tr> <td> <div class="corner"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <th><div><input class="tablehead" type="text" value="Schüler" readonly="readonly"></div></th> </tr> </table> </div> </td>
// Prüfung ob zwei mal das selbe PW eingegeben wurde. if ($pw1 !== $pw2) { "<h4 style='color:red;'>Sie haben nicht zweimal das selbe Passwort eingegeben!</h4>"; } // speichern bei korrekter Eingabe if (count($user_infos) == 0) { $u = new User(); $u->setLogin($nick); $u->setPasswd($pw1); $u->setAktiv(TRUE); $u->setEmail($mail); $u->setGeburtstag($bday); $u->save(); if ($typ == 1) { //Schueler $s = new Schueler(); $s->setVorname($vname); $s->setNachname($nname); $s->setKlasse_id($klasse[0]); $s->setUser_id($u->getId()); $s->setAktiv(TRUE); $s->save(); } elseif ($typ == 2) { //Lehrer $l = new Lehrer(); $l->setVorname($vname); $l->setNachname($nname); $l->setKlasse_ids($klasse); $l->setUser_id($u->getId()); $l->setAktiv(TRUE); $l->save();
public function getRole() { $l = new Lehrer(); if ($lehrer_id = $l->isLehrer($this->user_id)) { $l->load($lehrer_id); return $l; } else { $s = new Schueler(); if ($schueler_id = $s->isSchueler($this->user_id)) { $s->load($schueler_id); return $s; } } }