Exemple #1
0
 /** 查询某sql的结果条数 */
 public static long queryCount(Dao dao, String sql) {
   Sql sql2 =
       Sqls.fetchInt(
           "select count(1) from (" + sql + ") as _nutz_tmp_" + System.currentTimeMillis());
   dao.execute(sql2);
   return sql2.getInt();
 }
Exemple #2
0
  /**
   * 通过特定的sql查询出用户按服务时间大小倒叙排序的总条数
   *
   * @param str
   * @return
   */
  public int findSqlCount(String str, String table) {
    Sql sql = Sqls.create("select count(*)  from " + table + " where id in (" + str + ")");
    sql.setCallback(
        new SqlCallback() {

          public Object invoke(Connection arg0, ResultSet rs, Sql sql) throws SQLException {
            while (rs.next()) {

              return rs.getInt(1);
            }
            return null;
          }
        });
    dao.execute(sql);
    return sql.getInt();
  }