Changed login/logout process
This commit is contained in:
@@ -35,76 +35,6 @@ class Post extends \Core\Model
|
||||
);
|
||||
}
|
||||
|
||||
public function showAll($conditions = [])
|
||||
{
|
||||
try {
|
||||
$db = static::connectDB();
|
||||
|
||||
$sql = "SELECT * FROM pengumuman";
|
||||
|
||||
if ($conditions) {
|
||||
$sql .= " WHERE";
|
||||
foreach ($conditions as $condition) {
|
||||
|
||||
$keys[] = $condition[0];
|
||||
$operators[] = $condition[1];
|
||||
$values[] = $condition[2];
|
||||
}
|
||||
|
||||
$x = 1;
|
||||
$i = 0;
|
||||
foreach ($keys as $key) {
|
||||
$sql .= " $key $operators[$i] ?";
|
||||
$i++;
|
||||
|
||||
$x++;
|
||||
if ($x <= count($keys)) {
|
||||
$sql .= " AND";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$query = $db->prepare($sql);
|
||||
|
||||
if ($conditions) {
|
||||
$x = 1;
|
||||
foreach ($values as $value) {
|
||||
$query->bindValue($x, $value);
|
||||
$x++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($query->execute()) {
|
||||
if ($query->rowCount() != 0) {
|
||||
$result = $query->fetchAll(\PDO::FETCH_ASSOC);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
throw new \Exception($e->getMessage, 444);
|
||||
}
|
||||
}
|
||||
|
||||
public function showSingle($id)
|
||||
{
|
||||
try {
|
||||
$db = static::connectDB();
|
||||
|
||||
$sql = "SELECT * FROM pengumuman WHERE id = ?";
|
||||
|
||||
$query = $db->prepare($sql);
|
||||
|
||||
if ($query->execute([$id])) {
|
||||
if ($query->rowCount() === 1) {
|
||||
$result = $query->fetch(\PDO::FETCH_ASSOC);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
throw new \Exception($e->getMessage(), 444);
|
||||
}
|
||||
}
|
||||
|
||||
public function showCategories()
|
||||
{
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user