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}