Categories now have their background color and font color, which effects the client and admin side

This commit is contained in:
2017-09-15 16:32:26 +07:00
parent ec548a46b7
commit 9ca1050979
6 changed files with 231 additions and 110 deletions

View File

@@ -27,6 +27,8 @@ class Post extends \Core\Model
[
'id int(3) NOT NULL AUTO_INCREMENT',
'category varchar(20) NOT NULL',
'background char(7) NOT NULL DEFAULT "#ffffff"',
'foreground char(7) NOT NULL DEFAULT "#000000"',
'status tinyint(1) NOT NULL DEFAULT 1',
'PRIMARY KEY (id)'
],
@@ -114,6 +116,56 @@ class Post extends \Core\Model
}
}
public function showJoin($conditions = [])
{
try {
$db = static::connectDB();
$sql = "SELECT pengumuman.id, kategori.background, kategori.foreground, pengumuman.valid_at, pengumuman.expired_at, pengumuman.content, pengumuman.status FROM pengumuman INNER JOIN kategori ON pengumuman.category=kategori.id";
if ($conditions) {
$sql .= " WHERE";
foreach ($conditions as $condition) {
$keys[] = $condition[0];
$operators[] = $condition[1];
$values[] = $condition[2];
}
$x = 0;
foreach ($keys as $key) {
$sql .= " $key $operators[$x] ?";
$x++;
if ($x < count($keys)) {
$sql .= " AND";
}
}
}
$query = $db->prepare($sql);
if (count($conditions)) {
$x = 1;
foreach ($values as $value) {
$query->bindValue($x, $value);
$x++;
}
}
$query->execute();
if ($query->rowCount() == 1) {
$result = $query->fetch(\PDO::FETCH_ASSOC);
} elseif ($query->rowCount() > 1) {
$result = $query->fetchAll(\PDO::FETCH_ASSOC);
} else {
return false;
}
return $result;
} catch (PDOException $e) {
throw new \Exception($e->getMessage(), 444);
}
}
public function entry($args, $table = 'pengumuman')
{
if (count($args)) {
@@ -144,8 +196,6 @@ class Post extends \Core\Model
try {
$sql = "INSERT INTO {$table} ({$keys}) VALUES {$values}";
var_dump($sql);
var_dump($args);
$db = static::connectDB();