1b61c1a44e329fd4dc821d9a52a209bbc5fc9775 galt Mon Jul 1 16:49:12 2013 -0700 simplifying sql abuses of sqlGetField diff --git src/hg/hgGene/ctd.c src/hg/hgGene/ctd.c index f151a56..3593745 100644 --- src/hg/hgGene/ctd.c +++ src/hg/hgGene/ctd.c @@ -3,54 +3,54 @@ #include "common.h" #include "hash.h" #include "linefile.h" #include "dystring.h" #include "cheapcgi.h" #include "spDb.h" #include "hgGene.h" #include "hdb.h" #include "net.h" static boolean ctdExists(struct section *section, struct sqlConnection *conn, char *geneId) /* Return TRUE if CTD database exists and it has an entry with the gene symbol */ { -char condStr[255]; +char query[1024]; char *geneSymbol; if (isRgdGene(conn)) { if (sqlTableExists(conn, "rgdGene2Xref") == FALSE) return FALSE; } else { if (sqlTableExists(conn, "kgXref") == FALSE) return FALSE; } if (sqlTableExists(conn, "hgFixed.ctdSorted") == TRUE) { if (isRgdGene(conn)) { - sqlSafefFrag(condStr, sizeof(condStr), - "x.info=c.GeneSymbol and infoType = 'Name' and rgdGeneId='%s' limit 1", geneId); - geneSymbol = sqlGetField(database, "rgdGene2Xref x, hgFixed.ctdSorted c", - "ChemicalId", condStr); + sqlSafef(query, sizeof(query), "select ChemicalId from rgdGene2Xref x, hgFixed.ctdSorted c" + " where x.info=c.GeneSymbol and infoType = 'Name' and rgdGeneId='%s' limit 1", geneId); + geneSymbol = sqlQuickString(conn, query); } else { - sqlSafefFrag(condStr, sizeof(condStr), "x.geneSymbol=c.GeneSymbol and kgId='%s' limit 1", geneId); - geneSymbol = sqlGetField(database, "kgXref x, hgFixed.ctdSorted c", "ChemicalId", condStr); + sqlSafef(query, sizeof(query), "select ChemicalId from kgXref x, hgFixed.ctdSorted c" + " where x.geneSymbol=c.GeneSymbol and kgId='%s' limit 1", geneId); + geneSymbol = sqlQuickString(conn, query); } if (geneSymbol != NULL) return(TRUE); } return(FALSE); } static void ctdPrint(struct section *section, struct sqlConnection *conn, char *geneId) /* Print out CTD section. */ { char query[256]; struct sqlResult *sr; char **row; char *chemId, *chemName;