diff options
author | Simon Rettberg | 2021-12-07 14:56:43 +0100 |
---|---|---|
committer | Simon Rettberg | 2021-12-07 14:56:43 +0100 |
commit | da29d71fb2ae51a3389352f100e297606477b62b (patch) | |
tree | 29f0105302980bd659dec5c4638aa85e390b3caf /modules-available/statistics/inc/hardwarequery.inc.php | |
parent | [eventlog] install: Fix SQL (diff) | |
download | slx-admin-da29d71fb2ae51a3389352f100e297606477b62b.tar.gz slx-admin-da29d71fb2ae51a3389352f100e297606477b62b.tar.xz slx-admin-da29d71fb2ae51a3389352f100e297606477b62b.zip |
[statistics/passthrough] Consider group<->location mapping for KCL
Diffstat (limited to 'modules-available/statistics/inc/hardwarequery.inc.php')
-rw-r--r-- | modules-available/statistics/inc/hardwarequery.inc.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/modules-available/statistics/inc/hardwarequery.inc.php b/modules-available/statistics/inc/hardwarequery.inc.php index 6b5662d4..2cded089 100644 --- a/modules-available/statistics/inc/hardwarequery.inc.php +++ b/modules-available/statistics/inc/hardwarequery.inc.php @@ -68,6 +68,32 @@ class HardwareQuery $this->columns[$prop] = "$tid.`value` AS `$prop`"; } + public function addJoin(bool $global, string $prop, string $jTable, string $jColumn, string $condColumn = '', $condVal = null) + { + if (isset($this->columns[$jTable])) + return; + if (!isset($this->columns[$prop])) { + $this->fillTableVars($global, $srcTable, $table, $column); + $tid = $this->id(); + $pid = $this->id(); + $this->joins[$prop] = "INNER JOIN $table $tid ON ($srcTable.$column = $tid.$column + AND $tid.prop = :$pid)"; + $this->args[$pid] = $prop; + } + $jtid = $this->id(); + $cond = ''; + if (!empty($condColumn)) { + $vid = $this->id(); + if (is_array($condVal)) { + $cond = " AND $jtid.`$condColumn` IN (:vid)"; + } else { + $cond = " AND $jtid.`$condColumn` = :vid"; + } + $this->args[$vid] = $condVal; + } + $this->joins[$jTable] = "INNER JOIN $jTable $jtid ON ($jtid.$jColumn = $tid.`value` $cond)"; + } + public function addMachineWhere(string $column, string $op, $value) { if (isset($this->columns[$column])) |