diff --git a/Libraries/db/query.php b/Libraries/db/query.php index 7820cf3..63d4679 100644 --- a/Libraries/db/query.php +++ b/Libraries/db/query.php @@ -1,8 +1,11 @@ table_name = $table_name; @@ -19,6 +22,10 @@ class Query { } } + public function set_order_by_column (string $order_by){ + $this->order_by = $order_by; + } + private function get_columns(){ $column_string=""; @@ -39,13 +46,21 @@ class Query { return $modifier; } + private function get_order_by(){ + $order_by=""; + if (!empty($this->order_by)){ + $order_by=" ORDER BY {$this->order_by}"; + } + return $order_by; + } + private function get_where() { $where = ""; return $where; } public function get_query_string(){ - $query = "SELECT {$this->get_columns()} FROM {$this->table_name}{$this->get_where()}{$this->get_limit()};"; + $query = "SELECT {$this->get_columns()} FROM {$this->table_name}{$this->get_where()}{$this->get_order_by()}{$this->get_limit()};"; return $query; } diff --git a/Libraries/table/class.php b/Libraries/table/class.php index 77b5aa3..edb1669 100644 --- a/Libraries/table/class.php +++ b/Libraries/table/class.php @@ -1,5 +1,9 @@ name = $name; } + + public function set_pretty_name(string $pretty_name){ + $this->pretty_name = $pretty_name; + } + + public function get_pretty_name(){ + $output=$this->name; + if (!empty($this->pretty_name)){ + $output=$this->pretty_name; + } + return $output; + } public function Load($db){ $res = $db->query($this->query->get_query_string()); @@ -108,7 +125,7 @@ class Table { } public function get_html(){ $output=""; - $output="{$output}
"; + $output="{$output}
{$this->get_pretty_name()}"; $output="{$output}
"; foreach ($this->rows as $row){ diff --git a/Libraries/table/get.php b/Libraries/table/get.php index 2ea5198..9d1f580 100644 --- a/Libraries/table/get.php +++ b/Libraries/table/get.php @@ -1,6 +1,7 @@ Load($db, ""); - -echo $table->get_html(); +echo $_SERVER['DOCUMENT_ROOT']; ?> diff --git a/crontab.php b/crontab.php index 0ae4401..3a28843 100644 --- a/crontab.php +++ b/crontab.php @@ -1,4 +1,9 @@ - + @@ -36,28 +41,23 @@
-
-
- All Crontabs -
-
-
Crontab
Created At
Last Modified
-
- query("SELECT crontab_path, crontab_created_timestamp, crontab_modified_timestamp FROM crontabs;"); +
+ set_pretty_name("Crontabs"); + $query = $table->get_query(); + $query->set_columns($columns); + $table->Load($db); + echo $table->get_html(); + ?> - while ($row = $res->fetchArray()){ - echo "
"; - echo "
{$row['crontab_path']}
{$row['crontab_created_timestamp']}
{$row['crontab_modified_timestamp']}
"; - echo "
"; - } - ?> -
-
- -
+
\ No newline at end of file diff --git a/database.php b/database.php index f59ac43..05189a8 100644 --- a/database.php +++ b/database.php @@ -1,3 +1,9 @@ +