Add. Use parameters in group_call.lua (#2093)

This commit is contained in:
Alexey Melnichuk 2016-11-18 20:22:33 +03:00 committed by FusionPBX
parent dc838c91c0
commit 0dc4ba137e
1 changed files with 19 additions and 7 deletions

View File

@ -34,8 +34,14 @@
--set the cache
if (XML_STRING == "-ERR NOT FOUND") then
--connect to the database
require "resources.functions.database_handle";
dbh = database_handle('system');
local Database = require "resources.functions.database";
local dbh = Database.new('system');
--include json library
local json
if (debug["sql"]) then
json = require "resources.functions.lunajson"
end
--exits the script if we didn't connect properly
assert(dbh:connected());
@ -44,17 +50,23 @@
if (domain_uuid == nil) then
--get the domain_uuid
if (domain_name ~= nil) then
sql = "SELECT domain_uuid FROM v_domains ";
sql = sql .. "WHERE domain_name = '" .. domain_name .."' ";
local sql = "SELECT domain_uuid FROM v_domains ";
sql = sql .. "WHERE domain_name = :domain_name";
local params = {domain_name = domain_name};
if (debug["sql"]) then
freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "\n");
freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n");
end
status = dbh:query(sql, function(rows)
dbh:query(sql, params, function(rows)
domain_uuid = rows["domain_uuid"];
end);
end
end
if not domain_uuid then
freeswitch.consoleLog("warning", "[xml_handler] Can not find domain name: " .. tostring(domain_name) .. "\n");
return
end
--build the call group array
sql = [[
select * from v_extensions
@ -65,7 +77,7 @@
freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "\n");
end
call_group_array = {};
status = dbh:query(sql, function(row)
dbh:query(sql, function(row)
call_group = row['call_group'];
--call_group = str_replace(";", ",", call_group);
tmp_array = explode(",", call_group);