aboutsummaryrefslogtreecommitdiff
path: root/lib/classes/SQLQuery.php
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+github@gmail.com>2022-02-03 14:13:06 +0100
committerMoritz Strohm <strohm@data-quest.de>2022-04-12 15:44:24 +0000
commit9b7bae8c79ccb90e7cc6508f85bd30dfc9aef120 (patch)
tree623d33fb731d97292209350a02c5f92db383bef3 /lib/classes/SQLQuery.php
parent07f7c722f182e180115d3dabfb92554dc6532ca2 (diff)
transfer changeset 59563 from svn
Diffstat (limited to 'lib/classes/SQLQuery.php')
-rwxr-xr-xlib/classes/SQLQuery.php20
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/classes/SQLQuery.php b/lib/classes/SQLQuery.php
index a6539fb..2904fc1 100755
--- a/lib/classes/SQLQuery.php
+++ b/lib/classes/SQLQuery.php
@@ -95,12 +95,12 @@ class SQLQuery
unset($this->settings['where'][$name]);
} elseif ($parameter === null && $condition !== null) {
$this->settings['where'][$name] = $name;
- $this->settings['parameter'] = array_merge((array) $this->settings['parameter'], $condition);
+ $this->settings['parameter'] = array_merge((array) ($this->settings['parameter'] ?? []), $condition);
} elseif ($condition === null) {
$this->settings['where'][md5($name)] = $name;
} else {
$this->settings['where'][$name] = $condition;
- $this->settings['parameter'] = array_merge((array) $this->settings['parameter'], $parameter);
+ $this->settings['parameter'] = array_merge((array) ($this->settings['parameter'] ?? []), $parameter);
}
return $this;
}
@@ -218,7 +218,7 @@ class SQLQuery
$sql = "SELECT `{$this->settings['table']}`.* ";
}
- foreach ((array) $this->settings['select'] as $alias => $statement) {
+ foreach ((array) ($this->settings['select'] ?? []) as $alias => $statement) {
$sql .= $statement ? "{$statement} AS {$alias} " : $alias;
}
@@ -268,25 +268,27 @@ class SQLQuery
protected function getQuery()
{
$sql = "FROM `{$this->settings['table']}` ";
+ if (isset($this->settings['joins']) && is_array($this->settings['joins'])) {
foreach ($this->settings['joins'] as $alias => $joindata) {
$table = isset($joindata['table']) ? "{$joindata['table']} AS {$alias}" : $alias;
$on = isset($joindata['on']) ? " ON ({$joindata['on']})" : '';
- $sql .= " " . (isset($joindata['join']) ? $joindata['join'] : 'INNER JOIN') . " {$table}{$on} ";
+ $sql .= " " . ($joindata['join'] ?? 'INNER JOIN') . " {$table}{$on} ";
+ }
}
- if ($this->settings['where']) {
+ if (isset($this->settings['where'])) {
$sql .= "WHERE (" . implode(") AND (", $this->settings['where']) . ") ";
}
- if ($this->settings['groupby']) {
+ if (isset($this->settings['groupby'])) {
$sql .= "GROUP BY {$this->settings['groupby']} ";
}
- if ($this->settings['having']) {
+ if (isset($this->settings['having'])) {
$sql .= "HAVING (" . implode(") AND (", $this->settings['having']) . ") ";
}
- if ($this->settings['order']) {
+ if (isset($this->settings['order'])) {
$sql .= "ORDER BY {$this->settings['order']} ";
}
- if ($this->settings['limit']) {
+ if (isset($this->settings['limit']) && is_array($this->settings['limit'])) {
$sql .= "LIMIT ". (int) $this->settings['limit'][0] . ", " . (int) $this->settings['limit'][1] . " ";
}
return $sql;