summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kamailio-model.lua23
-rw-r--r--kamailio-viewtable-html.lsp3
2 files changed, 24 insertions, 2 deletions
diff --git a/kamailio-model.lua b/kamailio-model.lua
index 7937ea8..896a50f 100644
--- a/kamailio-model.lua
+++ b/kamailio-model.lua
@@ -315,8 +315,17 @@ function list_table_entries(table)
-- Get the devices from the DB
local res, err = pcall(function()
local connected = databaseconnect()
- retval.entries.value = getselectresponse("SELECT * FROM "..table.." ORDER BY id ASC") or {}
- retval.fields.value = listcolumns(table) or {}
+ local tables = listtables()
+ retval.table.errtxt = "Table does not exist"
+ errtxt = "Table does not exist"
+ for i,t in ipairs(tables) do
+ if t == table then
+ retval.table.errtxt = nil
+ errtxt = nil
+ retval.entries.value = getselectresponse("SELECT * FROM "..table.." ORDER BY id ASC") or {}
+ retval.fields.value = listcolumns(table) or {}
+ end
+ end
if connected then databasedisconnect() end
end)
if not res and err then
@@ -389,6 +398,16 @@ function update_table_entry(entry, create)
if success then
local res, err = pcall(function()
local connected = databaseconnect()
+ local tables = listtables()
+ success = false
+ entry.value.table.errtxt = "Table does not exist"
+ for i,t in ipairs(tables) do
+ if t == entry.value.table.value then
+ success = true
+ entry.value.table.errtxt = nil
+ break
+ end
+ end
if success and not create then
local sql = "SELECT * FROM "..entry.value.table.value.." WHERE id='"..escape(entry.value.id.value).."'"
local tmp = getselectresponse(sql)
diff --git a/kamailio-viewtable-html.lsp b/kamailio-viewtable-html.lsp
index f0c5ff9..28d4e13 100644
--- a/kamailio-viewtable-html.lsp
+++ b/kamailio-viewtable-html.lsp
@@ -41,6 +41,9 @@
</TR>
<% end %>
</TABLE>
+<% if form.errtxt then %>
+<p class="error"><%= html.html_escape(form.errtxt) %></p>
+<% end %>
<% if #form.value.entries.value == 0 then %>
<p>No entries found</p>
<% end %>