diff options
author | Frédéric Guillot <fguillot@users.noreply.github.com> | 2014-04-26 20:04:39 -0400 |
---|---|---|
committer | Frédéric Guillot <fguillot@users.noreply.github.com> | 2014-04-26 20:04:39 -0400 |
commit | 6551609d1b248011d301080c1be7c48085dc5d55 (patch) | |
tree | 0b09326b95232338f9f61dfe6268ced206e5b78b /vendor/PicoDb/Table.php | |
parent | 3332949c8baae581ea70ce5c61bb2a6225100422 (diff) |
Add a filter by user and due date + minor changes
Diffstat (limited to 'vendor/PicoDb/Table.php')
-rw-r--r-- | vendor/PicoDb/Table.php | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/vendor/PicoDb/Table.php b/vendor/PicoDb/Table.php index 494e350a..8a0ce644 100644 --- a/vendor/PicoDb/Table.php +++ b/vendor/PicoDb/Table.php @@ -4,6 +4,9 @@ namespace PicoDb; class Table { + const SORT_ASC = 'ASC'; + const SORT_DESC = 'DESC'; + private $table_name = ''; private $sql_limit = ''; private $sql_offset = ''; @@ -259,10 +262,10 @@ class Table } - public function orderBy($column, $order = 'ASC') + public function orderBy($column, $order = self::SORT_ASC) { $order = strtoupper($order); - $order = $order === 'ASC' || $order === 'DESC' ? $order : 'ASC'; + $order = $order === self::SORT_ASC || $order === self::SORT_DESC ? $order : self::SORT_ASC; if ($this->sql_order === '') { $this->sql_order = ' ORDER BY '.$this->db->escapeIdentifier($column).' '.$order; @@ -278,10 +281,10 @@ class Table public function asc($column) { if ($this->sql_order === '') { - $this->sql_order = ' ORDER BY '.$this->db->escapeIdentifier($column).' ASC'; + $this->sql_order = ' ORDER BY '.$this->db->escapeIdentifier($column).' '.self::SORT_ASC; } else { - $this->sql_order .= ', '.$this->db->escapeIdentifier($column).' ASC'; + $this->sql_order .= ', '.$this->db->escapeIdentifier($column).' '.self::SORT_ASC; } return $this; @@ -291,10 +294,10 @@ class Table public function desc($column) { if ($this->sql_order === '') { - $this->sql_order = ' ORDER BY '.$this->db->escapeIdentifier($column).' DESC'; + $this->sql_order = ' ORDER BY '.$this->db->escapeIdentifier($column).' '.self::SORT_DESC; } else { - $this->sql_order .= ', '.$this->db->escapeIdentifier($column).' DESC'; + $this->sql_order .= ', '.$this->db->escapeIdentifier($column).' '.self::SORT_DESC; } return $this; |