zoukankan      html  css  js  c++  java
  • 大二下学期团队项目(分类查询)

    今日主要完成了,查询排序页面的bug修改,之前写的查询排序对于热门(根据评论人数确定)排序有问题,经过排查是因为存入数据库的人数是字符串,数据库按字符串进行的排序。还有日期问题,日期中有日期与上映的地点,这样的话也不能按时间进行排序。

    所以将数据库的scorenum的类型改为了int,对于日期中的杂乱数据进行了清除。

    def update_time_num():
        cursor = None
        conn = None
        conn, cursor = get_conn()
        i = 5904;
        while i <=5906:
            print(i)
            i_str = '%s' % i
            i = i + 1
            # sql = "select meet from paper_data where id=" + i_str
            # cursor.execute(sql)
            # res = cursor.fetchall()
            # if(res!=()):
            # title_update=replace(res[0][0])
            try:
                sql_0="select scorenum from moviebean where id ="+i_str
                cursor.execute(sql_0)
                res = cursor.fetchall()
                print(res)
                print(res[0][0][1:len(res[0][0])])
                sql = "update  moviebean set scorenum = %s where id=" + i_str
                cursor.execute(sql, [res[0][0][1:len(res[0][0])]])
            except:
                traceback.print_exc()
                print("无此id", i)
        conn.commit()
    
    
    def find_class_order(str):
        sql="select title,star,director,score,date_time,area,type_movie,scorenum,img from moviebean where 1=1 " 
            "and (type_movie like "+"'%"+str[0]+"%'"+") and (date_time like "+"'%"+str[1]+"%'"+") and(area like "+"'%"+str[2]+"%'"+") "
        if(str[3]=="star_1"):
            sql=sql+" order by score desc "
        if(str[3]=="star_0"):
            sql=sql+" order by score "
        if(str[3]=="hot_1"):
            sql=sql+" order by scorenum desc "
        if(str[3]=="hot_0"):
            sql=sql+" order by scorenum "
        if(str[3]=="time_1"):
            sql=sql+" order by date_time desc "
        if(str[3]=="time_0"):
            sql=sql+" order by date_time "
        sql=sql+"limit "+str[4]+",20 "
        print(sql)
        res = query(sql)
        print(res)
        return res
  • 相关阅读:
    iOS项目的目录结构和开发流程
    XCode SVN设置
    iOS 登录 注册
    ios开发常用技巧
    iOS问题解答
    iOS设计模式
    iOS开发:打包应用程序
    iOS 封装
    iOS开发常用宏
    Objective-C 类,实例成员,静态变量,对象方法,类方法(静态方法),对象
  • 原文地址:https://www.cnblogs.com/fengchuiguobanxia/p/14762938.html
Copyright © 2011-2022 走看看