VPR_Schnittstelle/Model/istTeilModel.php

74 lines
1.5 KiB
PHP
Raw Normal View History

2023-12-06 08:57:17 +01:00
<?php
2024-01-14 17:51:11 +01:00
namespace ppb\Model;
2023-12-06 08:57:17 +01:00
2024-01-14 17:51:11 +01:00
//Programmiert von Stefan Groß
//getestet von Samuel Wolff
2023-12-06 08:57:17 +01:00
2024-01-14 17:51:11 +01:00
class istTeilModel extends Database
{
2023-12-06 08:57:17 +01:00
2024-01-14 17:51:11 +01:00
public function selectIstTeil()
{
$pdo = $this->linkDB();
2023-12-06 08:57:17 +01:00
2024-01-14 17:51:11 +01:00
$sql = "SELECT * FROM istTeil";
2023-12-06 08:57:17 +01:00
2024-01-14 17:51:11 +01:00
try {
$stmt = $pdo->prepare($sql);
$stmt->execute();
} catch (\PDOException $e) {
return false;
}
$results = $stmt->fetchAll(\PDO::FETCH_ASSOC);
foreach ($results as $key => $value) {
$results[$key]["bid"] += 0;
$results[$key]["gid"] += 0;
$results[$key]["id"] += 0;
}
return $results;
2023-12-06 08:57:17 +01:00
}
2024-01-14 17:51:11 +01:00
public function insertIstTeil($data)
{
$pdo = $this->linkDB();
$params = array();
$sql = "INSERT INTO istTeil (bid, gid) VALUES (:bid, :gid)";
foreach ($data as $key => $value) {
$params[":" . $key] = $value;
}
try {
$stmt = $pdo->prepare($sql);
$stmt->execute($params);
} catch (\PDOException $e) {
return false;
}
return true;
2023-12-06 08:57:17 +01:00
}
2024-01-14 17:51:11 +01:00
public function deleteIstTeil($id)
{
$pdo = $this->linkDB();
2023-12-06 08:57:17 +01:00
2024-01-14 17:51:11 +01:00
$params = array();
2023-12-06 08:57:17 +01:00
2024-01-14 17:51:11 +01:00
$sql = "DELETE FROM istTeil WHERE id = :id";
2023-12-06 08:57:17 +01:00
2024-01-14 17:51:11 +01:00
$params[":id"] = $id;
2023-12-06 08:57:17 +01:00
try {
$stmt = $pdo->prepare($sql);
2024-01-14 17:51:11 +01:00
$stmt->execute($params);
} catch (\PDOException $e) {
2023-12-06 08:57:17 +01:00
return false;
}
2024-01-14 17:51:11 +01:00
return true;
2023-12-06 08:57:17 +01:00
}
}
?>