Commit 88e2a9a7 authored by Ted Trask's avatar Ted Trask

Change the UPDATE syntax so also works on sqlite

parent a23e376f
......@@ -290,16 +290,19 @@ function mymodule.update_table_entry(dbase, self, entry, action, create)
local sql
local names = {}
local values = {}
if create then
for n,v in pairs(entry.value.fields.value) do
if create or not reversekeyfields[n] then
names[#names+1] = n
values[#values+1] = get_field_value(db, self, entry, n)
end
end
if create then
sql = "INSERT INTO "..db.escape(entry.value.table.value).." ("..table.concat(names, ", ")..") VALUES("..table.concat(values, ", ")..")"
else
sql = "UPDATE "..db.escape(entry.value.table.value).." SET ("..table.concat(names, ", ")..") = ("..table.concat(values, ", ")..") WHERE "..table.concat(fieldchecks, " AND ")
for n,v in pairs(entry.value.fields.value) do
if not reversekeyfields[n] then
values[#values+1] = n.."="..get_field_value(db, self, entry, n)
end
end
sql = "UPDATE "..db.escape(entry.value.table.value).." SET "..table.concat(values, ", ").." WHERE "..table.concat(fieldchecks, " AND ")
end
db.runsqlcommand(sql)
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment