We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 735ca88 + 773b700 commit 43b2118Copy full SHA for 43b2118
resources/lib/UnitySQL.php
@@ -2,6 +2,7 @@
2
3
namespace UnityWebPortal\lib;
4
5
+use Exception;
6
use PDO;
7
8
class UnitySQL
@@ -278,8 +279,14 @@ public function getSiteVar($name)
278
279
$stmt->bindParam(":name", $name);
280
281
$stmt->execute();
-
282
- return $stmt->fetchAll()[0]['value'];
+ $result = $stmt->fetchAll();
283
+ if (empty($result)) {
284
+ throw new Exception("Site variable with name '$name' not found.");
285
+ }
286
+ if (count($result) > 1) {
287
+ throw new Exception("Multiple site variables found with name '$name'. Expected only one.");
288
289
+ return $result[0]['value'];
290
}
291
292
public function updateSiteVar($name, $value)
0 commit comments