Update the method to connect to the database with lua.
This commit is contained in:
@@ -30,7 +30,8 @@
|
|||||||
digit_timeout = 5000;
|
digit_timeout = 5000;
|
||||||
|
|
||||||
--connect to the database
|
--connect to the database
|
||||||
dbh = freeswitch.Dbh(database["system"]);
|
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||||
|
dbh = database_handle('system');
|
||||||
|
|
||||||
--prepare the api object
|
--prepare the api object
|
||||||
api = freeswitch.API();
|
api = freeswitch.API();
|
||||||
@@ -139,7 +140,8 @@
|
|||||||
end_epoch = os.time();
|
end_epoch = os.time();
|
||||||
|
|
||||||
--connect to the database
|
--connect to the database
|
||||||
dbh = freeswitch.Dbh(database["system"]);
|
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||||
|
dbh = database_handle('system');
|
||||||
|
|
||||||
--get the conference sessions
|
--get the conference sessions
|
||||||
if (conference_session_uuid) then
|
if (conference_session_uuid) then
|
||||||
|
|||||||
@@ -49,7 +49,8 @@
|
|||||||
password_tries = 0;
|
password_tries = 0;
|
||||||
|
|
||||||
--connect to the database
|
--connect to the database
|
||||||
dbh = freeswitch.Dbh(database["system"]);
|
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||||
|
dbh = database_handle('system');
|
||||||
|
|
||||||
--set the api
|
--set the api
|
||||||
api = freeswitch.API();
|
api = freeswitch.API();
|
||||||
|
|||||||
@@ -36,7 +36,8 @@
|
|||||||
debug["info"] = false;
|
debug["info"] = false;
|
||||||
|
|
||||||
--connect to the database
|
--connect to the database
|
||||||
dbh = freeswitch.Dbh(database["system"]);
|
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||||
|
dbh = database_handle('system');
|
||||||
|
|
||||||
--used to stop the lua service
|
--used to stop the lua service
|
||||||
local file = assert(io.open(tmp_file, "w"));
|
local file = assert(io.open(tmp_file, "w"));
|
||||||
|
|||||||
@@ -42,7 +42,11 @@
|
|||||||
dofile(scripts_dir.."/resources/functions/explode.lua");
|
dofile(scripts_dir.."/resources/functions/explode.lua");
|
||||||
|
|
||||||
--connect to the database
|
--connect to the database
|
||||||
dbh = freeswitch.Dbh(database["system"]);
|
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||||
|
dbh = database_handle('system');
|
||||||
|
|
||||||
|
--exits the script if we didn't connect properly
|
||||||
|
assert(dbh:connected());
|
||||||
|
|
||||||
--if the params class and methods do not exist then add them to prevent errors
|
--if the params class and methods do not exist then add them to prevent errors
|
||||||
if (not params) then
|
if (not params) then
|
||||||
|
|||||||
@@ -33,7 +33,8 @@
|
|||||||
dofile(scripts_dir.."/resources/config.lua");
|
dofile(scripts_dir.."/resources/config.lua");
|
||||||
|
|
||||||
--connect to the database
|
--connect to the database
|
||||||
dbh = freeswitch.Dbh(database["system"]);
|
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||||
|
dbh = database_handle('system');
|
||||||
|
|
||||||
if (session:ready()) then
|
if (session:ready()) then
|
||||||
--get the variables
|
--get the variables
|
||||||
|
|||||||
@@ -40,7 +40,8 @@
|
|||||||
dofile(scripts_dir.."/resources/functions/mkdir.lua");
|
dofile(scripts_dir.."/resources/functions/mkdir.lua");
|
||||||
|
|
||||||
--connect to the database
|
--connect to the database
|
||||||
dbh = freeswitch.Dbh(database["system"]);
|
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||||
|
dbh = database_handle('system');
|
||||||
|
|
||||||
--make sure the scripts/run dir exists
|
--make sure the scripts/run dir exists
|
||||||
mkdir(scripts_dir .. "/run");
|
mkdir(scripts_dir .. "/run");
|
||||||
|
|||||||
@@ -29,7 +29,8 @@
|
|||||||
dofile(scripts_dir.."/resources/config.lua");
|
dofile(scripts_dir.."/resources/config.lua");
|
||||||
|
|
||||||
--connect to the database
|
--connect to the database
|
||||||
dbh = freeswitch.Dbh(database["system"]);
|
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||||
|
dbh = database_handle('system');
|
||||||
|
|
||||||
--add a trim function
|
--add a trim function
|
||||||
function trim (s)
|
function trim (s)
|
||||||
|
|||||||
@@ -37,7 +37,8 @@
|
|||||||
dofile(scripts_dir.."/resources/config.lua");
|
dofile(scripts_dir.."/resources/config.lua");
|
||||||
|
|
||||||
--connect to the database
|
--connect to the database
|
||||||
dbh = freeswitch.Dbh(database["system"]);
|
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||||
|
dbh = database_handle('system');
|
||||||
|
|
||||||
if ( session:ready() ) then
|
if ( session:ready() ) then
|
||||||
session:answer();
|
session:answer();
|
||||||
|
|||||||
@@ -42,7 +42,8 @@
|
|||||||
dofile(scripts_dir.."/resources/config.lua");
|
dofile(scripts_dir.."/resources/config.lua");
|
||||||
|
|
||||||
--connect to the database
|
--connect to the database
|
||||||
dbh = freeswitch.Dbh(database["system"]);
|
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||||
|
dbh = database_handle('system');
|
||||||
|
|
||||||
--prepare the api object
|
--prepare the api object
|
||||||
api = freeswitch.API();
|
api = freeswitch.API();
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ extension = argv[1];
|
|||||||
--dbh = freeswitch.Dbh("core:core"); -- when using sqlite
|
--dbh = freeswitch.Dbh("core:core"); -- when using sqlite
|
||||||
dbh = freeswitch.Dbh("sqlite://"..database_dir.."/core.db");
|
dbh = freeswitch.Dbh("sqlite://"..database_dir.."/core.db");
|
||||||
else
|
else
|
||||||
dbh = freeswitch.Dbh(database["switch"]);
|
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||||
|
dbh = database_handle('switch');
|
||||||
end
|
end
|
||||||
|
|
||||||
--exits the script if we didn't connect properly
|
--exits the script if we didn't connect properly
|
||||||
|
|||||||
@@ -39,7 +39,8 @@
|
|||||||
--dbh = freeswitch.Dbh("core:core"); -- when using sqlite
|
--dbh = freeswitch.Dbh("core:core"); -- when using sqlite
|
||||||
dbh = freeswitch.Dbh("sqlite://"..database_dir.."/core.db");
|
dbh = freeswitch.Dbh("sqlite://"..database_dir.."/core.db");
|
||||||
else
|
else
|
||||||
dbh = freeswitch.Dbh(database["switch"]);
|
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||||
|
dbh = database_handle('switch');
|
||||||
end
|
end
|
||||||
|
|
||||||
--exits the script if we didn't connect properly
|
--exits the script if we didn't connect properly
|
||||||
|
|||||||
@@ -36,7 +36,8 @@
|
|||||||
dofile(scripts_dir.."/resources/config.lua");
|
dofile(scripts_dir.."/resources/config.lua");
|
||||||
|
|
||||||
--connect to the database
|
--connect to the database
|
||||||
dbh = freeswitch.Dbh(database["system"]);
|
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||||
|
dbh = database_handle('system');
|
||||||
|
|
||||||
--get the variables
|
--get the variables
|
||||||
domain_name = session:getVariable("domain_name");
|
domain_name = session:getVariable("domain_name");
|
||||||
|
|||||||
@@ -21,7 +21,8 @@
|
|||||||
--connect to the database
|
--connect to the database
|
||||||
--dbh = freeswitch.Dbh("core:core"); -- when using sqlite
|
--dbh = freeswitch.Dbh("core:core"); -- when using sqlite
|
||||||
dbh = freeswitch.Dbh("sqlite://"..database_dir.."/park.db");
|
dbh = freeswitch.Dbh("sqlite://"..database_dir.."/park.db");
|
||||||
--dbh = freeswitch.Dbh(database["system"]);
|
--dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||||
|
--dbh = database_handle('system');
|
||||||
|
|
||||||
--exits the script if we didn't connect properly
|
--exits the script if we didn't connect properly
|
||||||
assert(dbh:connected());
|
assert(dbh:connected());
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
--connect to the database
|
--connect to the database
|
||||||
--dbh = freeswitch.Dbh("core:core"); -- when using sqlite
|
--dbh = freeswitch.Dbh("core:core"); -- when using sqlite
|
||||||
dbh = freeswitch.Dbh("sqlite://"..database_dir.."/park.db");
|
dbh = freeswitch.Dbh("sqlite://"..database_dir.."/park.db");
|
||||||
--dbh = freeswitch.Dbh(database["system"]);
|
--dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||||
|
|
||||||
--get the argv values
|
--get the argv values
|
||||||
script_name = argv[0];
|
script_name = argv[0];
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
--connect to the database
|
||||||
|
function database_handle(t)
|
||||||
|
if (t == "system") then
|
||||||
|
return freeswitch.Dbh(database["system"]);
|
||||||
|
elseif (t == "switch") then
|
||||||
|
return freeswitch.Dbh(database["switch"]);
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
|
|
||||||
--add the trim function
|
--add the trim function
|
||||||
function trim(s)
|
function trim(s)
|
||||||
return s:gsub("^%s+", ""):gsub("%s+$", "")
|
if (s) then
|
||||||
|
return s:gsub("^%s+", ""):gsub("%s+$", "")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
@@ -29,7 +29,8 @@
|
|||||||
dofile(scripts_dir.."/resources/config.lua");
|
dofile(scripts_dir.."/resources/config.lua");
|
||||||
|
|
||||||
--connect to the database
|
--connect to the database
|
||||||
dbh = freeswitch.Dbh(database["system"]);
|
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||||
|
dbh = database_handle('system');
|
||||||
|
|
||||||
--get the variables
|
--get the variables
|
||||||
if (session:ready()) then
|
if (session:ready()) then
|
||||||
|
|||||||
Reference in New Issue
Block a user