Changed login/logout process

This commit is contained in:
2017-09-08 10:05:42 +07:00
parent 8eb9005642
commit 8956b17434
6 changed files with 148 additions and 212 deletions

View File

@@ -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 {