# Path: config/setting.py



from config.setting import db
#encoding=utf-8

def get_by_id(id):
    row = db.select("work",what="id,title",where="id=$id",vars={"id":id})
    if row:
        return row[0]
    else:
        return None

def has(title):
    row = db.select("work",where="title=$title",vars={"title":title});
    return row and row[0]["id"] or None 

def add(title):
    id = has(title)
    if id:
        return id
    else:

# Path: config/setting.py



# Path: model/work.py
from config.setting import db

#encoding=utf-8

def get_by_id(id):
    row = db.select("work",what="id,title",where="id=$id",vars={"id":id})
    if row:
        return row[0]
    else:
        return None

def has(title):
    row = db.select("work",where="title=$title",vars={"title":title});
    return row and row[0]["id"] or None 

def add(title):
    id = has(title)
    if id:
        return id
    else:

        return db.insert("work",title=title) 