procedureHandler.php (1190B)
1 <?php 2 class ProcedureHandler implements PostHandler { 3 function handlePostData($postData) { 4 if (isset($postData['OperationType']) && $postData['OperationType'] == 'EXECUTE') { 5 try { 6 $db = dbconnection::getInstance(); 7 $pdo = $db->getPdo(); 8 9 if (isset($postData['Function'])) { 10 11 $procedureName = $postData['Function']; 12 unset($postData['Function'], $postData['OperationType']); 13 14 $questionMarks = array_fill(0, count($postData), '?'); 15 $sql = "CALL {$procedureName}(" . implode(", ", $questionMarks) . ")"; 16 17 $stmt = $pdo->prepare($sql); 18 19 $stmt->execute(array_values($postData)); 20 } 21 } catch(PDOException $e) { 22 echo "Error: " . $e->getMessage(); 23 } 24 25 RefreshTables(); 26 } 27 } 28 29 public function getOperationType() { 30 return "INSERT"; 31 } 32 } 33 ?>