+ String concat = "group_concat(concat('/', `name`, '=', REPLACE(REPLACE(value, '\\\\', '\\\\\\\\'), '/', '\\\\/')))";
+ GigiPreparedStatement ps = DatabaseConnection.getInstance().prepare("SELECT certs.id, " + concat + " as subject, md, csr_name, crt_name,memid, profile, certs.serial FROM `certs` LEFT JOIN certAvas ON certAvas.certid=certs.id WHERE serial=? GROUP BY certs.id");
+ ps.setString(1, serial);
+ GigiResultSet rs = ps.executeQuery();
+ return new Certificate(rs);
+ } catch (IllegalArgumentException e) {
+
+ }
+ return null;
+ }
+
+ public static Certificate getById(int id) {
+
+ // TODO caching?
+ try {
+ String concat = "group_concat(concat('/', `name`, '=', REPLACE(REPLACE(value, '\\\\', '\\\\\\\\'), '/', '\\\\/')))";
+ GigiPreparedStatement ps = DatabaseConnection.getInstance().prepare("SELECT certs.id, " + concat + " as subject, md, csr_name, crt_name,memid, profile, certs.serial FROM `certs` LEFT JOIN certAvas ON certAvas.certid=certs.id WHERE certs.id=? GROUP BY certs.id");
+ ps.setInt(1, id);
+ GigiResultSet rs = ps.executeQuery();
+
+ return new Certificate(rs);