sql语句是这样的: select * FROM (select *, (select count(1) from organize_course oc where o.uid =oc.organize_uid) AS course_num, (SELECT count(1) FROM organize_course oc WHERE o.uid =oc.organize_uid AND oc.status=1)as onsale_num, (SELECT COUNT(1) FROM organize_member om WHERE o.uid =om.organize_uid AND member_role =2) AS stu_num, (SELECT COUNT(1) FROM social_like sc WHERE o.uid =sc.target_uid ) AS fans_num from organize o ORDER BY #para(orderType) #para(orderMode)) as temp
下面的是报错信息:
com.jfinal.core.ActionHandler.error /organize/listOrganize?page=1&order_type=course_num&order_mode=DESC com.jfinal.plugin.activerecord.ActiveRecordException: java.sql.SQLException: sql injection violation, syntax error: syntax error, error in :'nize o ?) as temp ',expect RPAREN, actual QUES o : select count(*) from (select *, (select count(1) from organize_course oc where o.uid =oc.organize_uid) AS course_num, (SELECT count(1) FROM organize_course oc WHERE o.uid =oc.organize_uid AND oc.status=1)as onsale_num, (SELECT COUNT(1) FROM organize_member om WHERE o.uid =om.organize_uid AND member_role =2) AS stu_num, (SELECT COUNT(1) FROM social_like sc WHERE o.uid =sc.target_uid ) AS fans_num from organize o ?) as temp
解决办法是最外套一层select :
select * from ( 原 sql ) as temp
这里有详细的说明:
https://www.jfinal.com/doc/5-6