mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-30 17:24:16 +02:00
AbstractQuery implements QueryInterface, added addColumn, fixed sort
This commit is contained in:
parent
86945152b4
commit
1eb0fcdff8
@ -4,7 +4,7 @@ namespace Icinga\Data;
|
|||||||
|
|
||||||
use Icinga\Exception;
|
use Icinga\Exception;
|
||||||
|
|
||||||
abstract class AbstractQuery
|
abstract class AbstractQuery implements QueryInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Sort ascending
|
* Sort ascending
|
||||||
@ -72,6 +72,17 @@ abstract class AbstractQuery
|
|||||||
$this->init();
|
$this->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function addColumn($name, $alias = null)
|
||||||
|
{
|
||||||
|
// TODO: Fail if adding column twice, but allow same col with new alias
|
||||||
|
if ($alias === null) {
|
||||||
|
$this->columns[] = $name;
|
||||||
|
} else {
|
||||||
|
$this->columns[$alias] = $name;
|
||||||
|
}
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function getDatasource()
|
public function getDatasource()
|
||||||
{
|
{
|
||||||
return $this->ds;
|
return $this->ds;
|
||||||
@ -158,7 +169,7 @@ abstract class AbstractQuery
|
|||||||
$col = substr($col, 0, $pos);
|
$col = substr($col, 0, $pos);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (strtoupper($dir) === 'DESC') {
|
if ($dir === self::SORT_DESC || strtoupper($dir) === 'DESC') {
|
||||||
$dir = self::SORT_DESC;
|
$dir = self::SORT_DESC;
|
||||||
} else {
|
} else {
|
||||||
$dir = self::SORT_ASC;
|
$dir = self::SORT_ASC;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user