最佳回答
0
烟尘 Lv6 高级互助 发布于2021-4-2 15:59(编辑于 2021-4-2 16:27)
where 1=1
${if(参数==1||参数==2," and a=1"," and b=1")}
复选框返回字符串:
${if(find("1",参数)>0||find("2",参数)>0," and a=1"," and b=1")}
复选框返回数组:
${if(inarray(1,参数)>0||inarray(2,参数)>0," and a=1"," and b=1")}
建议返回数组,字符串的话如果有12判断会出错
Qian同学(提问者)
- 如果参数是复选框呢,,传过来的是字符串 1,2,3 不能用==了吧
烟尘 回复 Qian同学(提问者)
- ${if(find(\"1\",参数)>0||find(\"2\",参数)>0,\" and a=1\",\" and b=1\")}
烟尘 回复 Qian同学(提问者)
- 要保证其他选项没有1,就是10,11,12之类的都没有,返回字符串才能正确判断
Qian同学(提问者)
- 其实我复选框返回的都是中文,用字符串返回应该没有问题吧
烟尘 回复 Qian同学(提问者)
- 只要没有类似于【a】、【ab】这样的一项包含另一项全部的情况就没问题
取消
评论
最佳回答
0
CD20160914 Lv8 专家互助 发布于2021-4-2 16:01
${if(or(find("1",p)>0,find("2",p)>0)," and a=1"," and b=1")}
最佳回答
0
被子 Lv7 见习互助 发布于2021-4-2 16:05
--方法一
${
if(参数=1,"
select * from 订单 where 1=1 and a=1
","
select * from 订单 where 1=1 and b=1
")
}
--方法二
select * from 订单 where 1=1 ${if(参数==1||参数==2," and a=1"," and b=1")}
最佳回答
0
梦想的初衷 Lv7 初级互助 发布于2021-4-2 16:07
可以试下这个
${if(参数=="1","
SELECT
*
FROM 表
where
条件1
"," ")}
${if(参数="2","
SELECT
*
FROM 表
where
条件2
"," ")}
Qian同学(提问者)
- 如果参数是复选框呢,,传过来的是字符串 1,2,3 不能用==了吧
梦想的初衷 回复 Qian同学(提问者)
- ${if(and(参数=\"\",参数=\"2\"),\"
SELECT
*
FROM 表
where
条件1
\",\" \")}
梦想的初衷 回复 Qian同学(提问者)
- 刚试过前面加个and 就可以
Qian同学(提问者) 回复 梦想的初衷
- 也非常感谢您
取消
评论