TableModel etc

master
E. Almqvist 3 years ago
parent bcf642d6a9
commit b4e674b9e6
  1. 1
      src/app.rb
  2. 15
      src/db_models.rb

@ -7,6 +7,7 @@ require "sqlite3"
require "sassc"
require_relative "database.rb"
require_relative "db_models.rb"
require_relative "func.rb"
enable :sessions

@ -4,13 +4,24 @@ class TableModel # Base model
@table_name = table_name
end
private def get(entity, filter="")
private def gen_update_query(vars, values)
end
private def get(attr, filter="")
db = db_handle # get the db handle
query = "SELECT #{entity} FROM #{@table_name} " # create the query string
query = "SELECT #{attr} FROM #{@table_name} " # create the query string
if filter != "" then query += "WHERE #{filter}" end
db.execute query
end
private def set(attr, filter="")
if self.get(attr, filter).length > 0 then
query = "UPDATE #{attr} SET var = ?, var2 = ?"
else
end
end
end

Loading…
Cancel
Save