From 6551609d1b248011d301080c1be7c48085dc5d55 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Sat, 26 Apr 2014 20:04:39 -0400 Subject: Add a filter by user and due date + minor changes --- vendor/PicoDb/Table.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'vendor') 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; -- cgit v1.2.3