Closed woobai closed 8 years ago
String select = " select c.*,cnt.title content_title,u.username";
StringBuilder fromBuilder = new StringBuilder(" from comment c");
fromBuilder.append(" left join content cnt on c.content_id = cnt.id");
fromBuilder.append(" left join user u on c.user_id = u.id ");
LinkedList<Object> params = new LinkedList<Object>();
boolean needWhere = true;
needWhere = appendIfNotEmpty(fromBuilder, "c.`type`", type, params, needWhere);
needWhere = appendIfNotEmpty(fromBuilder, " c.content_module", module, params, needWhere);
needWhere = appendIfNotEmpty(fromBuilder, " c.`status`", status, params, needWhere);
needWhere = appendIfNotEmpty(fromBuilder, " cnt.id", contentId, params, needWhere);
82-86可做如下修改:
StringBuilder sqlBuilder = new StringBuilder("select c.*,cnt.title content_title,u.username");
sqlBuilder.append(" from comment c");
sqlBuilder.append(" left join content cnt on c.content_id = cnt.id");
sqlBuilder.append(" left join user u on c.user_id = u.id ");
sqlBuilder.append(" where c.id = ?");
return super.paginate(pageNumber, pageSize, tc(select), tc(sqlExceptSelect), paras);
哦,sorry,最新代码已经修改了
给文章添加评论后,再次访问该文章,无法访问,后台报错