diff --git a/library/Icinga/Protocol/Livestatus/Query.php b/library/Icinga/Protocol/Livestatus/Query.php index dc90c5e88..f719029db 100644 --- a/library/Icinga/Protocol/Livestatus/Query.php +++ b/library/Icinga/Protocol/Livestatus/Query.php @@ -19,121 +19,6 @@ class Query extends SimpleQuery protected $order_columns = array(); protected $count = false; - public function __construct(Connection $connection) - { - $this->connection = $connection; - } - - public function getAdapter() - { - return $this->connection; - } - - public function compare(& $a, & $b, $col_num = 0) - { - if (! array_key_exists($col_num, $this->order_columns)) { - return 0; - } - $col = $this->order_columns[$col_num][0]; - $dir = $this->order_columns[$col_num][1]; - - //$res = strnatcmp(strtolower($a->$col), strtolower($b->$col)); - $res = strcmp(strtolower($a->$col), strtolower($b->$col)); - if ($res === 0) { - if (array_key_exists(++$col_num, $this->order_columns)) { - return $this->compare($a, $b, $col_num); - } else { - return 0; - } - } - if ($dir === self::SORT_ASC) { - return $res; - } else { - return $res * -1; - } - } - - public function hasOrder() - { - return ! empty($this->order_columns); - } - - public function where($key, $val = null) - { - $this->filters[$key] = $val; - return $this; - } - - public function order($col) - { - if (($pos = strpos($col, ' ')) === false) { - $col = $col; - $dir = self::SORT_ASC; - } else { - $dir = strtoupper(substr($col, $pos + 1)); - if ($dir === 'DESC') { - $dir = self::SORT_DESC; - } else { - $dir = self::SORT_ASC; - } - $col = substr($col, 0, $pos); - } - $this->order_columns[] = array($col, $dir); - return $this; - } - - // Nur wenn keine stats, sonst im RAM!! - // Offset gibt es nicht, muss simuliert werden - public function limit($count = null, $offset = null) - { - if (! preg_match('~^\d+~', $count . $offset)) { - throw new IcingaException( - 'Got invalid limit: %s, %s', - $count, - $offset - ); - } - $this->limit_count = (int) $count; - $this->limit_offset = (int) $offset; - return $this; - } - - public function hasLimit() - { - return $this->limit_count !== null; - } - - public function hasOffset() - { - return $this->limit_offset > 0; - } - - public function getLimit() - { - return $this->limit_count; - } - - public function getOffset() - { - return $this->limit_offset; - } - - public function from($table, $columns = null) - { - if (! $this->connection->hasTable($table)) { - throw new IcingaException( - 'This livestatus connection does not provide "%s"', - $table - ); - } - $this->table = $table; - if (is_array($columns)) { - // TODO: check for valid names? - $this->columns = $columns; - } - return $this; - } - public function hasColumns() { return $this->columns !== null;