def get_unread_message_count(uid): fields = ['count(*) as cnt'] result = select_all(XVZD_PREFIX__ + 'message', fields, conds={ 'recv_uid': uid, 'readed': None }) return result[0].get('cnt')
def get_list(board, page=1, limit=10): page -= 1 if page < 0: page = 1 order = 'desc' page_offset = page * limit if page_offset > sys.maxint: page_offset = 0 fields = ['no', 'title', 'uid', 'regdate', 'pinned'] return select_all(XVZD_PREFIX__+board, fields, order=order, limit='%d, %d'%(page_offset, limit))
def get_sended_message(uid, page, limit=10): order = 'desc' page -= 1 if page < 0: page = 1 page_offset = page * limit if page_offset > sys.maxint: page_offset = 0 fields = [ 'no', 'recv_uid', 'send_uid', 'readed', 'title', 'content', 'regdate' ] return select_all(XVZD_PREFIX__ + 'message', fields, {'send_uid': uid}, order=order, limit='%d, %d' % (page_offset, limit))
def get_message_count(uid, limit=10): fields = ['count(*) as cnt'] result = select_all(XVZD_PREFIX__ + 'message', fields) return result[0].get('cnt')
def get_all_notice(): return select_all(__XVDZ_PREFIX__ + 'notice', ['no', 'title', 'content', 'uid'])
def get_users(): fields = ['uid', 'id', 'name', 'password'] return select_all(XVZD_PREFIX__ + 'users', fields)
def get_articles(board): order = 'desc' fields = ['no', 'title', 'uid', 'regdate', 'pinned'] return select_all(XVZD_PREFIX__+board, fields, order=order)
def get_pinned(board): fields = ['no', 'title', 'uid', 'regdate', 'pinned'] return select_all(XVZD_PREFIX__+board, fields, conds={'pinned': 1})
def get_endpage(board, limit=10): fields = ['count(*) as cnt'] result = select_all(XVZD_PREFIX__+board, fields) return (int(result[0].get('cnt')) - 1) / limit + 1