Skip to content

Commit 6f689d2

Browse files
committed
Merge branch 'main' into request-name-volatile
2 parents c523e2e + f99ae09 commit 6f689d2

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

resources/lib/UnitySQL.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,16 @@ private function execute($statement)
5151

5252
private function search($table, $filters)
5353
{
54-
$stmt = $this->conn->prepare(
55-
"SELECT * FROM $table WHERE " .
56-
implode(" and ", array_map(fn($x) => "$x=:$x", array_keys($filters)))
57-
);
58-
foreach ($filters as $key => $val) {
59-
$stmt->bindValue(":$key", $val);
54+
if (count($filters) > 0) {
55+
$stmt = $this->conn->prepare(
56+
"SELECT * FROM $table WHERE " .
57+
implode(" and ", array_map(fn($x) => "$x=:$x", array_keys($filters)))
58+
);
59+
foreach ($filters as $key => $val) {
60+
$stmt->bindValue(":$key", $val);
61+
}
62+
} else {
63+
$stmt = $this->conn->prepare("SELECT * FROM $table");
6064
}
6165
$this->execute($stmt);
6266
return $stmt->fetchAll();

0 commit comments

Comments
 (0)