Add. Use params in destination_caller_id.lua (#2123)

This commit is contained in:
Alexey Melnichuk
2016-11-21 22:03:46 -07:00
committed by FusionPBX
parent 076a02b41c
commit 86f25f5f34
@@ -28,8 +28,14 @@
require "resources.functions.config"; require "resources.functions.config";
--connect to the database --connect to the database
require "resources.functions.database_handle"; local Database = require "resources.functions.database";
dbh = database_handle('system'); dbh = Database.new('system');
--include json library
local json
if (debug["sql"]) then
json = require "resources.functions.lunajson"
end
--define the trim function --define the trim function
require "resources.functions.trim" require "resources.functions.trim"
@@ -45,9 +51,12 @@
--caller_id_number = session:getVariable("caller_id_number"); --caller_id_number = session:getVariable("caller_id_number");
--get the destination_number --get the destination_number
sql = [[ SELECT * FROM v_destinations sql = "SELECT destination_number FROM v_destinations where destination_number like :destination_number";
where destination_number like '1]].. outbound_area_code ..[[%']] local params = {destination_number = '1'.. outbound_area_code .. '%'};
freeswitch.consoleLog("notice", "SQL:" .. sql .. "\n"); if (debug["sql"]) then
freeswitch.consoleLog("notice", "SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n");
end
x = 0; x = 0;
dbh:query(sql, function(row) dbh:query(sql, function(row)
destination_number = row.destination_number; destination_number = row.destination_number;