From 15b9b33a5f13c5e553be324eb66c41ea947d23c2 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Tue, 22 Nov 2016 08:03:46 +0300 Subject: [PATCH] Add. Use params in destination_caller_id.lua (#2123) --- .../install/scripts/destination_caller_id.lua | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/resources/install/scripts/destination_caller_id.lua b/resources/install/scripts/destination_caller_id.lua index df105bd919..deabb52baf 100644 --- a/resources/install/scripts/destination_caller_id.lua +++ b/resources/install/scripts/destination_caller_id.lua @@ -28,8 +28,14 @@ require "resources.functions.config"; --connect to the database - require "resources.functions.database_handle"; - dbh = database_handle('system'); + local Database = require "resources.functions.database"; + dbh = Database.new('system'); + +--include json library + local json + if (debug["sql"]) then + json = require "resources.functions.lunajson" + end --define the trim function require "resources.functions.trim" @@ -45,9 +51,12 @@ --caller_id_number = session:getVariable("caller_id_number"); --get the destination_number - sql = [[ SELECT * FROM v_destinations - where destination_number like '1]].. outbound_area_code ..[[%']] - freeswitch.consoleLog("notice", "SQL:" .. sql .. "\n"); + sql = "SELECT destination_number FROM v_destinations where destination_number like :destination_number"; + local params = {destination_number = '1'.. outbound_area_code .. '%'}; + if (debug["sql"]) then + freeswitch.consoleLog("notice", "SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n"); + end + x = 0; dbh:query(sql, function(row) destination_number = row.destination_number;