Wow! Nice trick, thanks a lot :)It works great but I am still a bit wonder why my script worked fine with old version of FS.2016-03-08 21:29 GMT+03:00 Abaci B <abaci64@gmail.com>:I shortened and changed your function a little, can you try it and se if it makes a difference?BTW you can also shorten the set to a single execution by using "multiset"local dbh = freeswitch.Dbh("name", "root", "passwd")
function get_global_vars()
local res = {}
my_query = "select var_name, var_value from directory_global_vars where domain_id='1'"
assert(dbh:query(my_query, function(qrow)
if qrow["var_name"] and qrow["var_value"] then
table.insert(row, qrow["var_name"] .. "=" .. qrow["var_value"]);
end))
return res
endlocal row = get_global_vars()for i in ipairs(row) do
session:execute("set", "".. row[i] .."")
freeswitch.consoleLog("NOTICE","row[i] is '" .. row[i] .. "'\n")
endOn Tue, Mar 8, 2016 at 12:57 PM, Юрий Насида <ynasida@gmail.com> wrote:_________________________________________________________________________Hi list,I noted that my old lua script which I used a lot of years from FS 1.2 works very strange with FS 1.6The script is quite simple. I am using it for getting the list of variables from mysql and set as channel variables. Please look below.local dbh = freeswitch.Dbh("name", "root", "passwd")function get_global_vars()local row = {}local i = 1local mycount = 1my_query = "select var_name, var_value from directory_global_vars where domain_id='1'"assert(dbh:query(my_query, function(qrow)for key, val in pairs(qrow) doif mycount == 1 thenabc = valmycount = 2elseif mycount == 2 thenrow[i] = abc.."="..valmycount =1i = i+1endendend))return rowendlocal row = get_global_vars()for k in pairs(row) dosession:execute("set", "".. row[k] .."")freeswitch.consoleLog("NOTICE","row[k] is '" .. row[k] .. "'\n")endThe result in fs_cli should looks likeswitch_cpp.cpp:1356 simplescript startswitch_cpp.cpp:1356 row[k] is 'user_context=default'switch_cpp.cpp:1356 row[k] is 'numbering_plan=USCAN'BUT sometimes it looks like backwards!switch_cpp.cpp:1356 simplescript startswitch_cpp.cpp:1356 row[k] is 'default=user_context'switch_cpp.cpp:1356 row[k] is 'USCAN=numbering_plan'Please keep in mind that I do exactly same call without any changes but I have different results (its ~ 50%/50%)I am not sure but it looks like bug.Please advice.Thanks.
Professional FreeSWITCH Consulting Services:
consulting@freeswitch.org
http://www.freeswitchsolutions.com
Official FreeSWITCH Sites
http://www.freeswitch.org
http://confluence.freeswitch.org
http://www.cluecon.com
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
_________________________________________________________________________
Professional FreeSWITCH Consulting Services:
consulting@freeswitch.org
http://www.freeswitchsolutions.com
Official FreeSWITCH Sites
http://www.freeswitch.org
http://confluence.freeswitch.org
http://www.cluecon.com
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
_________________________________________________________________________
Professional FreeSWITCH Consulting Services:
consulting@freeswitch.org
http://www.freeswitchsolutions.com
Official FreeSWITCH Sites
http://www.freeswitch.org
http://confluence.freeswitch.org
http://www.cluecon.com
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org