NutzCN Logo
问答 Cnd 如何直接加Orderby?
发布于 2495天前 作者 zhangjianshe 2379 次浏览 复制 上一个帖子 下一个帖子
标签:

Cnd where=Cnd.New();
where.and(new Static(" order by id" );

9 回复

Cnd.orderBy()

我想要添加一个ordeby的 字符串

想生成怎样的sql?

select * from ABC order by ID asc,NAME desc ,其中 order by ID asc,NAME desc 是一个字符串

。。。 为毛(* ̄m ̄)要这样。。。

用1=1吧

不会是前端页面拼好传过来的吧?

 if (!Strings.isBlank(req.orderSql)) {
      if (req.filters.size() == 0) {
        where.and("1", "=", "1");
        where.and(new Static(" order by " + req.orderSql));
      } else {
        where.and(new Static(" order by " + req.orderSql));
      }
    } else {

    }

错误 'SELECT * FROM ADMIN_USER WHERE 1=? AND order by EXTRA_ID asc LIMIT 5, 5 '

Cnd where=Cnd.where.(new Static("1=1 order by id") );

但你从请求直接取值拼入sql,不怕注入?

添加回复
请先登陆
回到顶部