[Freeswitch-users] how to retrive data from mysql ODBC in chat.lua script ?

Shabbir abbasi shabbirabbasi92 at gmail.com
Tue Aug 12 11:58:41 MSD 2014


i am  testing  a script      new_chat.lua    script is below

#!/usr/bin/lua
local dbh = freeswitch.Dbh("odbc://dbname:db_username:db_passwd") --
connect to ODBC database
assert(dbh:connected()) -- exits the script if we didn't connect properly

if dbh:connected() == false then
   freeswitch.consoleLog("ALERT", "lua cannot connect to database" .. dsn
.. "\n");
end

sql_query    = "SELECT * FROM cc_card WHERE id ='197'"
dbh:query(sql_query ,function(row)
for key, val in pairs(row) do
key = val
end
 freeswitch.consoleLog("INFO"," inside  QUERY lastname = " .. row.lastname
.. "\n");
freeswitch.consoleLog("INFO"," inside  QUERY  redial = " .. row.redial ..
"\n");
end)

freeswitch.consoleLog("INFO"," outside  QUERY  lastname = " .. row.lastname
.. "\n");
freeswitch.consoleLog("INFO","  outside  QUERY    redial = " .. row.redial
.. "\n");

freeswitch.consoleLog("INFO"," outside  QUERY  lastname = " .. lastname ..
"\n");
freeswitch.consoleLog("INFO","  outside  QUERY    redial = " .. redial ..
"\n");

dbh:release() -- optional

but here is some problum    in this script  inside query lines are
working  but outside query lines  are not working  WHY  ??
any suggestions are very wellcome
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20140812/51b1b34d/attachment.html 


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