Compare commits
10 Commits
b6ec972c19
...
getBenutze
| Author | SHA1 | Date | |
|---|---|---|---|
| 694802e314 | |||
| b8f03d4321 | |||
| 137c0f7550 | |||
| 5caa672a26 | |||
| a8f4455c9d | |||
| 1826e9f61b | |||
| 1357e21155 | |||
| d4a67f0a30 | |||
| 2b14563643 | |||
| 9c82aec3c5 |
@@ -18,6 +18,18 @@ class BenutzerController
|
|||||||
$this->db = new BenutzerModel();
|
$this->db = new BenutzerModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getBenutzer() {
|
||||||
|
$result = $this->db->selectBenutzer();
|
||||||
|
if (isset($_GET["name"])) {
|
||||||
|
if ($result)
|
||||||
|
$result = $result[0];
|
||||||
|
else
|
||||||
|
$result = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return json_encode($result);
|
||||||
|
}
|
||||||
|
|
||||||
// Updated einen Benutzer
|
// Updated einen Benutzer
|
||||||
public function updateBenutzer($elternId, $data)
|
public function updateBenutzer($elternId, $data)
|
||||||
{
|
{
|
||||||
@@ -36,6 +48,14 @@ class BenutzerController
|
|||||||
return json_encode($data);
|
return json_encode($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function nextId()
|
||||||
|
{
|
||||||
|
$result = $this->db->nextId();
|
||||||
|
|
||||||
|
return json_encode($result);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -9,6 +9,37 @@ use ppb\Library\Msg;
|
|||||||
|
|
||||||
class BenutzerModel extends Database
|
class BenutzerModel extends Database
|
||||||
{
|
{
|
||||||
|
public function selectBenutzer()
|
||||||
|
{
|
||||||
|
$pdo = $this->linkDB();
|
||||||
|
|
||||||
|
$params = array();
|
||||||
|
|
||||||
|
$sql = "SELECT * FROM Benutzerkonto";
|
||||||
|
|
||||||
|
if(isset($_GET["name"])){
|
||||||
|
$params[":name"] = $_GET["name"];
|
||||||
|
$sql .= " WHERE name = :name";
|
||||||
|
}
|
||||||
|
|
||||||
|
//Ausführen des SQL befehls
|
||||||
|
try {
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$stmt->execute($params);
|
||||||
|
} catch (\PDOException $e) {
|
||||||
|
echo $e;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$result = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
|
||||||
|
//Die Datensätze werden nummeriert
|
||||||
|
foreach ($result as $key => $row) {
|
||||||
|
$result[$key]["id"] += 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -94,7 +125,25 @@ class BenutzerModel extends Database
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function nextId()
|
||||||
|
{
|
||||||
|
|
||||||
|
$pdo = $this->linkDB();
|
||||||
|
|
||||||
|
$sql = "SELECT `auto_increment` FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 'Benutzerkonto'; ";
|
||||||
|
|
||||||
|
try {
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$stmt->execute();
|
||||||
|
} catch (\PDOException $e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $stmt->fetchALL(\PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -15,11 +15,15 @@
|
|||||||
file_get_contents('php://input') die übergebenen json-Strings (für PUT/POST-Requests)
|
file_get_contents('php://input') die übergebenen json-Strings (für PUT/POST-Requests)
|
||||||
*/
|
*/
|
||||||
spl_autoload_register(function ($className) {
|
spl_autoload_register(function ($className) {
|
||||||
if (substr($className, 0, 4) !== 'ppb\\') { return; }
|
if (substr($className, 0, 4) !== 'ppb\\') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$fileName = __DIR__ . '/' . str_replace('\\', DIRECTORY_SEPARATOR, substr($className, 4)) . '.php';
|
$fileName = __DIR__ . '/' . str_replace('\\', DIRECTORY_SEPARATOR, substr($className, 4)) . '.php';
|
||||||
|
|
||||||
if (file_exists($fileName)) { include $fileName; }
|
if (file_exists($fileName)) {
|
||||||
|
include $fileName;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$endpoint = explode('/', trim($_SERVER['PATH_INFO'], '/'));
|
$endpoint = explode('/', trim($_SERVER['PATH_INFO'], '/'));
|
||||||
|
|||||||
Reference in New Issue
Block a user