summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics/inc/hardwarequery.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/statistics/inc/hardwarequery.inc.php')
-rw-r--r--modules-available/statistics/inc/hardwarequery.inc.php26
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]))