Auction stuff

master
E. Almqvist 3 years ago
parent 7cf860bb1a
commit a3073f36ec
  1. 18
      src/lib/database.rb
  2. 1
      src/views/stylesheets/style.sass

@ -50,6 +50,18 @@ class EntityModel
end end
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 def self.get(attr, filter="", *args) # get data from table
q = "SELECT #{attr} FROM #{self.name}" # create the query string q = "SELECT #{attr} FROM #{self.name}" # create the query string
q = apply_filter(q, filter) q = apply_filter(q, filter)
@ -65,9 +77,9 @@ class EntityModel
def self.insert(data) # Inserts new data into the table def self.insert(data) # Inserts new data into the table
entstr, valstr = self.gen_insert_query data.keys entstr, valstr = self.gen_insert_query data.keys
r = self.query( "INSERT INTO #{self.name} #{entstr} VALUES #{valstr}", *data.values ) dbbuf, resp = self.equery( "INSERT INTO #{self.name} #{entstr} VALUES #{valstr}", *data.values )
newid = db.last_insert_row_id newid = dbbuf.last_insert_row_id
return newid, r return newid, resp
end end
def self.set(attr, data, filter="") # slower but more lazy def self.set(attr, data, filter="") # slower but more lazy

@ -394,3 +394,4 @@ ul.button-container
opacity: 0 opacity: 0
100% 100%
opacity: 1 opacity: 1

Loading…
Cancel
Save