private static String buildQuery(String by,String keyword,int status,String fieldBy,
int fieldLimit,String timeby,Date begin,Date end,String order) {
StringBuffer query = new StringBuffer(" WHERE 1");
if (keyword!=null && keyword.length() > 0) {
query.append(" AND "+by+" LIKE "+quote("%"+keyword+"%"));
}
if (status!=-9) {
query.append(" AND status="+status);
}
if(fieldBy!=null) {
query.append(" AND "+fieldBy+fieldLimit);
}
if (begin!=null) {
query.append(" AND "+timeby+">" +quote(begin));
}
if (end!=null) {
query.append(" AND "+timeby+"<"+ quote(end));
}
if (order!=null) {
query.append(" ORDER BY "+ order);
query.insert(0,"SELECT * FROM "+TABLE);
}
else {
query.insert(0,"SELECT count(*) FROM "+TABLE);
}
// log.debug(query);
return query.toString();
}