diff --git a/src/lib/database.rb b/src/lib/database.rb index 6f3ac79..cb1cac6 100644 --- a/src/lib/database.rb +++ b/src/lib/database.rb @@ -50,6 +50,18 @@ class EntityModel end end + # Extended query that also returns database instance + def self.equery(q, *args) + Console.debug("Running extended SQL -> #{q}", *args) + begin + dbbuf = db + resp = dbbuf.execute( q, args ) + return dbbuf, resp + rescue SQLite3::SQLException => err + Console.error "SQL exception: #{err}", q + end + end + def self.get(attr, filter="", *args) # get data from table q = "SELECT #{attr} FROM #{self.name}" # create the query string q = apply_filter(q, filter) @@ -65,9 +77,9 @@ class EntityModel def self.insert(data) # Inserts new data into the table entstr, valstr = self.gen_insert_query data.keys - r = self.query( "INSERT INTO #{self.name} #{entstr} VALUES #{valstr}", *data.values ) - newid = db.last_insert_row_id - return newid, r + dbbuf, resp = self.equery( "INSERT INTO #{self.name} #{entstr} VALUES #{valstr}", *data.values ) + newid = dbbuf.last_insert_row_id + return newid, resp end def self.set(attr, data, filter="") # slower but more lazy diff --git a/src/views/stylesheets/style.sass b/src/views/stylesheets/style.sass index a59ff8a..b8bca33 100644 --- a/src/views/stylesheets/style.sass +++ b/src/views/stylesheets/style.sass @@ -394,3 +394,4 @@ ul.button-container opacity: 0 100% opacity: 1 +