コード例 #1
0
ファイル: server_ctg_req.py プロジェクト: SYNET/epg-server
def make_paging_str(http_req_args, db_req_args):
    paging_str = ''
    if not http_req_args.has_key('limit') and not http_req_args.has_key('count'):
        paging_str = 'LIMIT %d' % server_helper.limit_default
    for arg in server_helper.paging_params:
        if http_req_args.has_key(arg):
            paging_str += '%s %%s ' % arg.upper()
            server_helper.append_value(http_req_args, arg, 0, db_req_args)
    return paging_str
コード例 #2
0
ファイル: server_ctg_req.py プロジェクト: SYNET/epg-server
def make_ctg_where_str(http_req_args, db_req_args):
    where_str = ''
    for param in http_req_args.keys():
        if param in server_helper.where_params:
            if where_str != '':
                where_str += ' AND '

            if param == 'now':
                where_str += '(categories.start <= %s AND categories.end >= %s)'
                server_helper.append_value(http_req_args, param, 0, db_req_args)
                server_helper.append_value(http_req_args, param, 0, db_req_args)
            elif param == 'next':
                where_str += 'categories.start >= %s'
                server_helper.append_value(http_req_args, param, 0, db_req_args)
            elif param == 'start':
                where_str += '((categories.start >= %s) OR (categories.start <= %s and categories.end >= %s))'
                server_helper.append_value(http_req_args, param, 0, db_req_args)
                server_helper.append_value(http_req_args, param, 0, db_req_args)
                server_helper.append_value(http_req_args, param, 0, db_req_args)
            elif param == 'end':
                where_str += 'categories.end <= %s'
                server_helper.append_value(http_req_args, param, 0, db_req_args)
            elif param == 'ctg_id':
                # if there're more then one ctg_id
                # then we making compound id = (parent_ctg_id << 16 | ctg_id)
                # first ctg_id is parent id
                if len(http_req_args[param]) > 1:
                    where_str += 'categories.%s = %%s' % (param)
                    db_req_args.append(int(http_req_args[param][0]) << 16 | int(http_req_args[param][1]))
                else:
                    where_str += 'categories.%s = %%s' % (param)
                    server_helper.append_value(http_req_args, param, 0, db_req_args)
    if where_str != '':
        return 'WHERE ' + where_str
    return ''
コード例 #3
0
ファイル: server_plain_req.py プロジェクト: SYNET/epg-server
def make_where_str(http_req_args, db_req_args):
    where_str = ''
    for param in http_req_args.keys():
        if param in server_helper.where_params:
            if where_str != '':
                where_str += ' AND '

            if param == 'now':
                where_str += '(programs.start <= %s AND programs.end >= %s)'
                server_helper.append_value(http_req_args, param, 0, db_req_args)
                server_helper.append_value(http_req_args, param, 0, db_req_args)
            elif param == 'next':
                where_str += 'programs.start >= %s'
                server_helper.append_value(http_req_args, param, 0, db_req_args)
            elif param == 'start':
                where_str += '((programs.start >= %s) OR (programs.start <= %s and programs.end >= %s))'
                server_helper.append_value(http_req_args, param, 0, db_req_args)
                server_helper.append_value(http_req_args, param, 0, db_req_args)
                server_helper.append_value(http_req_args, param, 0, db_req_args)
            elif param == 'end':
                where_str += 'programs.start <= %s'
                server_helper.append_value(http_req_args, param, 0, db_req_args)
            elif len(http_req_args[param]) > 1:
                where_str += 'programs.%s in (' % (param)
                where_str += '%s,' * len(http_req_args[param])
                for i in range(0, len(http_req_args[param])):
                    server_helper.append_value(param, i, db_req_args)
                where_str = where_str[:-1]
                where_str += ')'
            else:
                where_str += 'programs.%s = %%s' % (param)
                server_helper.append_value(http_req_args, param, 0, db_req_args)
    if where_str != '':
        return 'WHERE ' + where_str
    return ''