Add a filter by user and due date + minor changes
This commit is contained in:
15
vendor/PicoDb/Table.php
vendored
15
vendor/PicoDb/Table.php
vendored
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user