All pastes #514490 Raw Edit

Unnamed

public text v1 · immutable
#514490 ·published 2007-05-27 19:34 UTC
rendered paste body
/**
	 * Get the id of the location name given in the parameter. On success return
	 * the id, on failure return 0
	 * 
	 * @param 	name	the location name
	 * @return	location id
	 */
	public int getLocationIdByName(String name) {
		String sql = "SELECT c.id FROM " + getTagTable() + " a INNER JOIN " + getComTable() + " b ON a.commentid = b.id INNER JOIN " + getTable() + " c ON a.taggedid = c.id WHERE b.topic = '" + name + "'";
		
		try {
			ResultSet rs = select(sql);
			if(! rs.next()) return 0;
			int lid = rs.getInt("id");
			rs.close();
			
			return lid;
		} catch (SQLException e) {
			e.printStackTrace();
			
			return 0;
		}
	}