From c56c582c37e62acb9a658def2dafdddff8386281 Mon Sep 17 00:00:00 2001 From: Ugnich Anton Date: Tue, 17 Jun 2014 18:40:08 +0700 Subject: getTagNoIndex --- src/com/juick/server/TagQueries.java | 49 +++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 14 deletions(-) (limited to 'src/com/juick/server') diff --git a/src/com/juick/server/TagQueries.java b/src/com/juick/server/TagQueries.java index b570c32a..938f7ace 100644 --- a/src/com/juick/server/TagQueries.java +++ b/src/com/juick/server/TagQueries.java @@ -29,10 +29,10 @@ import java.util.ArrayList; * @author Ugnich Anton */ public class TagQueries { - + public static com.juick.Tag getTag(Connection sql, String tag, boolean autoCreate) { com.juick.Tag ret = null; - + PreparedStatement stmt = null; ResultSet rs = null; try { @@ -50,32 +50,53 @@ public class TagQueries { } finally { Utils.finishSQL(rs, stmt); } - + if (ret == null && autoCreate) { ret = new com.juick.Tag(); ret.TID = createTag(sql, tag); ret.Name = tag; } - + return ret; } - + public static ArrayList getTags(Connection sql, String[] tags, boolean autoCreate) { ArrayList ret = new ArrayList(); - + for (int i = 0; i < tags.length; i++) { com.juick.Tag t = getTag(sql, tags[i], autoCreate); if (t != null) { ret.add(t); } } - + + return ret; + } + + public static boolean getTagNoIndex(Connection sql, int tag_id) { + boolean ret = false; + + PreparedStatement stmt = null; + ResultSet rs = null; + try { + stmt = sql.prepareStatement("SELECT noindex FROM tags_meta WHERE tag_id=?"); + stmt.setInt(1, tag_id); + rs = stmt.executeQuery(); + if (rs.first()) { + ret = rs.getInt(1) == 1; + } + } catch (SQLException e) { + System.err.println(e); + } finally { + Utils.finishSQL(rs, stmt); + } + return ret; } - + public static int createTag(Connection sql, String name) { int ret = 0; - + PreparedStatement stmt = null; ResultSet rs = null; try { @@ -91,13 +112,13 @@ public class TagQueries { } finally { Utils.finishSQL(rs, stmt); } - + return ret; } - + public static ArrayList getUserTagsAll(Connection sql, int uid) { ArrayList tags = new ArrayList(); - + PreparedStatement stmt = null; ResultSet rs = null; try { @@ -118,10 +139,10 @@ public class TagQueries { } return tags; } - + public static ArrayList getUserBLTags(Connection sql, int uid) { ArrayList tags = new ArrayList(); - + PreparedStatement stmt = null; ResultSet rs = null; try { -- cgit v1.2.3