diff options
Diffstat (limited to 'vendor/PicoDb')
-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; |