From 9dafe3620c94e9813f0ca3707206fc381ce7a7db Mon Sep 17 00:00:00 2001 From: Jordan Schultz Date: Thu, 7 Mar 2024 15:38:50 -0800 Subject: [PATCH 1/2] Added debug statements for query param --- WhatsAppAlerts.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/WhatsAppAlerts.php b/WhatsAppAlerts.php index 7dfb92c..03d4112 100644 --- a/WhatsAppAlerts.php +++ b/WhatsAppAlerts.php @@ -170,11 +170,14 @@ public function filterProjectsBySender($projects, $from_number) foreach ($projects as $local_pid) { $pid_phone_field = $this->getProjectSetting('inbound-phone-field', $local_pid); $this->emDebug("Checking project $local_pid for records with $pid_phone_field that is similar to $from_number"); + $this->emDebug("local PID $local_pid phone field $pid_phone_field"); + $sql = "SELECT record, event_id, value from redcap_data where project_id = ? and field_name = ?"; $result = $this->query( - "SELECT record, event_id, value from redcap_data where project_id = ? and field_name = ?", + $sql, [$local_pid, $pid_phone_field] ); while ($row = $result->fetch_assoc()) { + $this->emDebug("ROW val", $row); $record_phone_digits = $this->formatNumber($row['value'], ''); if (!empty($record_phone_digits) && $from_digits == $record_phone_digits) { $this->emDebug("Found an inbound match: " . json_encode($row)); From 742537edf7e79441ae863a81099cc88d39df9bbd Mon Sep 17 00:00:00 2001 From: Jordan Schultz Date: Thu, 7 Mar 2024 16:02:54 -0800 Subject: [PATCH 2/2] Corrected sql syntax --- WhatsAppAlerts.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/WhatsAppAlerts.php b/WhatsAppAlerts.php index 68dcbc8..028908d 100644 --- a/WhatsAppAlerts.php +++ b/WhatsAppAlerts.php @@ -174,11 +174,10 @@ public function filterProjectsBySender($projects, $from_number) $this->emDebug("Checking project $local_pid for records with $pid_phone_field that is similar to $from_number"); $this->emDebug("local PID $local_pid phone field $pid_phone_field"); $data_table = method_exists('\REDCap', 'getDataTable') ? \REDCap::getDataTable($local_pid) : "redcap_data"; - $sql = "SELECT record, event_id, value from ? where project_id = ? and field_name = ?"; $this->emDebug("$data_table"); $result = $this->query( - $sql, - [$data_table, $local_pid, $pid_phone_field] + "SELECT record, event_id, value from ". $data_table ." where project_id = ? and field_name = ?", + [$local_pid, $pid_phone_field] ); while ($row = $result->fetch_assoc()) { $this->emDebug("ROW val", $row);