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.php40
1 files changed, 17 insertions, 23 deletions
diff --git a/modules-available/statistics/inc/hardwarequery.inc.php b/modules-available/statistics/inc/hardwarequery.inc.php
index 4f0ec344..6b1b5043 100644
--- a/modules-available/statistics/inc/hardwarequery.inc.php
+++ b/modules-available/statistics/inc/hardwarequery.inc.php
@@ -45,25 +45,23 @@ class HardwareQuery
*/
public function addForeignJoin(bool $global, string $prop, string $jTable, string $jColumn, string $condColumn = '', $condVal = null)
{
- if (isset($this->columns[$jTable]))
+ if (isset($this->columns["$jTable.$prop"]))
return;
- if (!isset($this->columns[$prop])) {
- if ($global) {
- $srcTable = 'shw';
- $table = 'statistic_hw_prop';
- $column = 'hwid';
- } else {
- $srcTable = 'mxhw';
- $table = 'machine_x_hw_prop';
- $column = 'machinehwid';
- }
- $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;
- $this->columns[$prop] = "$tid.`value` AS `$prop`";
+ if ($global) {
+ $srcTable = 'shw';
+ $table = 'statistic_hw_prop';
+ $column = 'hwid';
+ } else {
+ $srcTable = 'mxhw';
+ $table = 'machine_x_hw_prop';
+ $column = 'machinehwid';
}
+ $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;
+ $this->columns[$prop] = "$tid.`value` AS `$prop`";
$jtid = $this->id();
$cond = '';
if (!empty($condColumn)) {
@@ -106,10 +104,8 @@ class HardwareQuery
/**
* Join the machine table and add the given column from it to the SELECT
- * @param string $column
- * @return void
*/
- public function addMachineColumn(string $column)
+ public function addMachineColumn(string $column): void
{
if (isset($this->columns[$column]))
return;
@@ -163,13 +159,11 @@ class HardwareQuery
} else {
$groupBy = '';
}
- $query = 'SELECT ' . implode(', ', $columns)
+ return 'SELECT ' . implode(', ', $columns)
. ' FROM statistic_hw shw '
. implode(' ', $this->joins)
. ' WHERE ' . implode(' AND ', $this->where)
. $groupBy;
- //error_log($query);
- return $query;
}
}