Add a filter by user and due date + minor changes

This commit is contained in:
Frédéric Guillot
2014-04-26 20:04:39 -04:00
parent 3332949c8b
commit 6551609d1b
14 changed files with 158 additions and 57 deletions

View File

@@ -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;