return 0;
}
public static LinkedList query(String query, int start, int limit) throws Exception {
LinkedList list = new LinkedList();
Connection conn = Sprout.connection(false);
PreparedStatement stmt = null;
ResultSet result = null;
String sql = null;
try {
sql = "SELECT DISTINCT n.id " + from(query) + " ORDER BY n.date DESC LIMIT " + start * limit + ", " + limit;
if(Sprout.SQL.driver().equals("org.postgresql.Driver")) {
sql = "SELECT DISTINCT n.node_date, n.node_id " + from(query) + " ORDER BY n.node_date DESC OFFSET " + start * limit + " LIMIT " + limit;
}
if(Sprout.SQL.driver().equals("oracle.jdbc.OracleDriver")) {
sql = "SELECT DISTINCT n.node_date, n.node_id " + from(query) + " AND ROWNUM BETWEEN " + start * limit + " AND " + (start * limit + limit) + " ORDER BY n.node_date DESC";
}
stmt = conn.prepareStatement(sql);
byte[] data = ("%" + query + "%").getBytes("UTF-8");
if(Sprout.SQL.driver().equals("oracle.jdbc.OracleDriver")) {
data = query.getBytes("UTF-8");
}
stmt.setBytes(1, data);
stmt.setBytes(2, data);
stmt.setBytes(3, data);
result = stmt.executeQuery();
while(result.next()) {
list.add(find(result.getLong(Sprout.SQL.driver().equals("com.mysql.jdbc.Driver") ? "id" : "node_id")));
}
} catch(SQLException e) {
throw e;
} finally {
if(result != null) {
result.close();
}
if(stmt != null) {
stmt.close();
}
if(conn != null && conn.getAutoCommit()) {
conn.close();
}
}
return list;
}