--[[
FreeSWITCH lua dbh debug and other utils
参数说明:
debug = 脚本执行日志
dbh = 数据库操作
用法:
备注:
--]]
ODBCName = "";
ODBCUser = "";
ODBCPwd = "";
debug = {} --freeSWITCH Script Log info
t_dbh = {} --freeSWITCH DBH
--create the DB handle
function t_dbh.connect()
dbh = freeswitch.Dbh("odbc://"..ODBCName..":"..ODBCUser..":"..ODBCPwd.."") -- connect to Mysql ODBC database
if(assert(dbh:connected())) then
freeswitch.consoleLog("notice","mysql db connected !\n");
end
end
-- release the Db handle
function t_dbh.close()
dbh:release()
end
-- query db
function t_dbh.query (queryString)
local table={};
local i = 1;
assert(dbh:query(queryString,function(row)
table[i]= row;
i=i+1;
end))
return table;
end;
-- exec update delete and modify
function t_dbh.exec(queryString)
-- local dbh = freeswitch.Dbh("odbc://"..ODBCName..":"..ODBCUser..":"..ODBCPass.."")
assert(dbh:query(queryString))
local affected_rows = dbh:affected_rows();
-- dbh:release() -- optional
return affected_rows ;
end
function GetFormatDate()
local date=os.date("%Y%m%d%H%M%S");
return date
end
function debug.var(k, v)
v = v or 'nil'
freeswitch.consoleLog("notice", " ====DebugVar=== " .. k .. ": " .. v .. "\n")
end
-- Log INFO
function debug.info(s)
freeswitch.consoleLog("info", "Script "..argv[0].." info :"..s .. "\n")
end
--Log NOTICE
function debug.notice(s)
freeswitch.consoleLog("notice", "Script "..argv[0].." notice :"..s .. "\n")
end
--Log ERR
function debug.err(s)
freeswitch.consoleLog("err", "Script "..argv[0].." error :"..s .. "\n");
end
FreeSWITCH lua dbh debug and other utils
参数说明:
debug = 脚本执行日志
dbh = 数据库操作
用法:
备注:
--]]
ODBCName = "";
ODBCUser = "";
ODBCPwd = "";
debug = {} --freeSWITCH Script Log info
t_dbh = {} --freeSWITCH DBH
--create the DB handle
function t_dbh.connect()
dbh = freeswitch.Dbh("odbc://"..ODBCName..":"..ODBCUser..":"..ODBCPwd.."") -- connect to Mysql ODBC database
if(assert(dbh:connected())) then
freeswitch.consoleLog("notice","mysql db connected !\n");
end
end
-- release the Db handle
function t_dbh.close()
dbh:release()
end
-- query db
function t_dbh.query (queryString)
local table={};
local i = 1;
assert(dbh:query(queryString,function(row)
table[i]= row;
i=i+1;
end))
return table;
end;
-- exec update delete and modify
function t_dbh.exec(queryString)
-- local dbh = freeswitch.Dbh("odbc://"..ODBCName..":"..ODBCUser..":"..ODBCPass.."")
assert(dbh:query(queryString))
local affected_rows = dbh:affected_rows();
-- dbh:release() -- optional
return affected_rows ;
end
function GetFormatDate()
local date=os.date("%Y%m%d%H%M%S");
return date
end
function debug.var(k, v)
v = v or 'nil'
freeswitch.consoleLog("notice", " ====DebugVar=== " .. k .. ": " .. v .. "\n")
end
-- Log INFO
function debug.info(s)
freeswitch.consoleLog("info", "Script "..argv[0].." info :"..s .. "\n")
end
--Log NOTICE
function debug.notice(s)
freeswitch.consoleLog("notice", "Script "..argv[0].." notice :"..s .. "\n")
end
--Log ERR
function debug.err(s)
freeswitch.consoleLog("err", "Script "..argv[0].." error :"..s .. "\n");
end