Example #1
0
def get_article_list(page):
    try:
        sql = "select id, title, publish_time, summary from article order by id desc limit %s, %s"
        cur_page = page+1
        all_page = db.get('select count(*) as count from article')
        all_page = all_page['count']/(page+1)
        articles = db.query(sql, page, page_count)
    except Exception, e:
        print e
        return {'err': -1, 'err_msg': '系统错误'}
Example #2
0
def manage_article(page):
    try:
        page = int(page)
        if page < 1:
            page = 0
        else:
            page = page-1
        sql = "select id, title, publish_time from article order by publish_time limit %s,%s"
        articles = db.query(sql, page*10, 10)
        return {'err': 0, 'articles': articles}
    except Exception, e:
        print e
        return {'err': -1, 'err_msg': 'system error'}
Example #3
0
def get_comment(article_id):
    sql = "select id, user_name, create_at, content, to_comment_id as cid, to_comment_username as cname" \
          " from comment where article_id = %s"
    comments = db.query(sql, article_id)
    return comments