mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-08 05:11:51 +00:00
Make dbh:connected accessible from Lua - thanks Grmt
This commit is contained in:
@@ -318,9 +318,9 @@ Dbh::Dbh(char *dsn, char *user, char *pass)
|
||||
options.odbc_options.pass = pass;
|
||||
|
||||
if (switch_cache_db_get_db_handle(&dbh, SCDB_TYPE_ODBC, &options) == SWITCH_STATUS_SUCCESS) {
|
||||
connected = true;
|
||||
m_connected = true;
|
||||
} else {
|
||||
connected = false;
|
||||
m_connected = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,14 +331,19 @@ Dbh::~Dbh()
|
||||
|
||||
bool Dbh::release()
|
||||
{
|
||||
if (connected) {
|
||||
if (m_connected) {
|
||||
switch_cache_db_release_db_handle(&dbh);
|
||||
connected = false;
|
||||
m_connected = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Dbh::connected()
|
||||
{
|
||||
return m_connected;
|
||||
}
|
||||
|
||||
int Dbh::query_callback(void *pArg, int argc, char **argv, char **cargv)
|
||||
{
|
||||
SWIGLUA_FN *lua_fun = (SWIGLUA_FN *)pArg;
|
||||
@@ -366,7 +371,7 @@ int Dbh::query_callback(void *pArg, int argc, char **argv, char **cargv)
|
||||
|
||||
bool Dbh::query(char *sql, SWIGLUA_FN lua_fun)
|
||||
{
|
||||
if (connected) {
|
||||
if (m_connected) {
|
||||
if (lua_fun.L) {
|
||||
if (switch_cache_db_execute_sql_callback(dbh, sql, query_callback, &lua_fun, NULL) == SWITCH_STATUS_SUCCESS) {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user