public ISelecter whereRightLike(String column, Object value) { Rule r = new Rule(); r.setColumn(column); r.setOpStart(" like "); wheres.add(r); paramWheres.add("%" + value); return this; }
public ISelecter column(String... column) { for (String c : column) { Rule rule = new Rule(); rule.setColumn(c); cols.add(rule); } return this; }
public ISelecter where(String sql) { Rule r = new Rule(); r.setColumn(sql); r.setOpStart(""); r.setTag(""); r.setOpEnd(""); wheres.add(r); return this; }
public IExecuter whereSql(String sql, Object[] values) { Rule r = new Rule(); r.setColumn(sql); r.setOpStart(""); r.setTag(""); r.setOpEnd(""); wheres.add(r); for (Object v : values) { paramWheres.add(v); } return this; }
public ISelecter whereNq(String column, Object value) { Rule r = new Rule(); r.setColumn(column); if (null != value) { r.setOpStart("!="); paramWheres.add(value); } else { r.setOpStart(" IS NOT NULL"); r.setTag(""); } wheres.add(r); return this; }
protected IExecuter whereNotIn(String column, Object... value) { Rule r = new Rule(); r.setColumn(column); r.setOpStart(" not in ("); r.setOpEnd(")"); StringBuilder tag = new StringBuilder(); List<Object> l = objectsToList(value); for (Object o : l) { tag.append(",?"); paramWheres.add(o); } r.setTag(l.size() > 0 ? tag.toString().substring(1) : ""); wheres.add(r); return this; }
protected String getWhereSql() { StringBuffer sql = new StringBuffer(); for (int i = 0, l = wheres.size(); i < l; i++) { if (i < 1) { sql.append(" WHERE"); } else { sql.append(" AND"); } sql.append(" "); Rule r = wheres.get(i); sql.append(r.getColumn()); sql.append(r.getOpStart()); sql.append(r.getTag()); sql.append(r.getOpEnd()); } return sql.toString(); }