createTable( 'pengumuman', [ 'id int(3) NOT NULL AUTO_INCREMENT', 'category int(3) NOT NULL', 'created_at date NOT NULL DEFAULT CURRENT_TIMESTAMP', 'valid_at date NOT NULL DEFAULT CURRENT_TIMESTAMP', 'expired_at date NOT NULL', 'creator int(3) NOT NULL', 'edited_at date', 'editor int(3)', 'content varchar(255) NOT NULL', 'status tinyint(1) NOT NULL DEFAULT 1', 'PRIMARY KEY (id)' ] ); // Create table for categories $this->createTable( 'kategori', [ 'id int(3) NOT NULL AUTO_INCREMENT', 'category varchar(20) NOT NULL', 'status tinyint(1) NOT NULL DEFAULT 1', 'PRIMARY KEY (id)' ] ); } public function showCategories() { try { $db = static::connectDB(); $sql = "SELECT * FROM kategori WHERE status = 1"; $query = $db->prepare($sql); if ($query->execute()) { if ($query->rowCount() > 1) { $results = $query->fetchAll(\PDO::FETCH_ASSOC); return $results; } } } catch (PDOException $e) { throw new \Exception($e->getMessage(), 444); } } }