commit 310361f0b88c997b9c9db6cd2a6d4fed57fa29eb
parent d3d23007267ca5b689e91a7f2d9f53de2b7d6249
Author: William Lindholm <william_lindholm@outlook.com>
Date: Tue, 3 Oct 2023 15:53:19 +0000
Refactoring.
Diffstat:
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/utils/procedureHandler.php b/utils/procedureHandler.php
@@ -7,22 +7,16 @@
$pdo = $db->getPdo();
if (isset($postData['Function'])) {
-
+
$procedureName = $postData['Function'];
unset($postData['Function'], $postData['OperationType']);
-
- $placeholders = array_keys($postData);
- $sql = "CALL {$procedureName}(" . implode(", ", array_map(function($p) {
- return ":$p";
- }, $placeholders)) . ")";
-
+
+ $questionMarks = array_fill(0, count($postData), '?');
+ $sql = "CALL {$procedureName}(" . implode(", ", $questionMarks) . ")";
+
$stmt = $pdo->prepare($sql);
-
- foreach ($postData as $key => $value) {
- $stmt->bindParam(":$key", $postData[$key]);
- }
-
- $stmt->execute();
+
+ if (!$stmt->execute(array_values($postData)));
}
} catch(PDOException $e) {
echo "Error: " . $e->getMessage();