[Freeswitch-users] strange things with freeswitch.Dbh at FS 1.6

Юрий Насида ynasida at gmail.com
Tue Mar 8 20:57:34 MSK 2016


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.6

The 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 = 1
local mycount = 1

my_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) do
  if mycount == 1 then
  abc = val
  mycount = 2
  elseif mycount == 2 then
  row[i] = abc.."="..val
  mycount =1
  i = i+1
  end
end

end))

return row

end


local row = get_global_vars()
for k in pairs(row) do
session:execute("set", "".. row[k] .."")
freeswitch.consoleLog("NOTICE","row[k]   is '" .. row[k] .. "'\n")
end


The result in fs_cli should looks like
 switch_cpp.cpp:1356  simplescript start
 switch_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 start
 switch_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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20160308/9b54bb07/attachment.html 


Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list