[codeface] [PATCH 1/5] Add query to insert new project

  • From: Mitchell Joblin <mitchell.joblin.ext@xxxxxxxxxxx>
  • To: codeface@xxxxxxxxxxxxx
  • Date: Thu, 29 Oct 2015 11:57:00 +0100

Signed-off-by: Mitchell Joblin <mitchell.joblin.ext@xxxxxxxxxxx>
---
codeface/R/db.r | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/codeface/R/db.r b/codeface/R/db.r
index b03a577..ff568bf 100644
--- a/codeface/R/db.r
+++ b/codeface/R/db.r
@@ -239,13 +239,24 @@ gen.clear.ml.id.con <- function(con, ml, pid) {
"WHERE projectId=", pid,
" AND name=", sq(ml)))
dbGetQuery(con, str_c("INSERT INTO mailing_list (projectID, name)",
- " VALUES (", pid, ", ", sq(ml), ")"))
+ " VALUES (", pid, ", ", sq(ml), ")"))
res <- dbGetQuery(con, str_c("SELECT id from mailing_list ",
"WHERE projectId=", pid,
" AND name=", sq(ml)))
return(res$id)
}

+## Insert new project
+gen.clear.project.id.con <- function(con, project.name, analysis.method) {
+ dbGetQuery(con, str_c("DELETE FROM project ",
+ "WHERE project.name=", sq(project.name)))
+ dat <- data.frame(name=project.name, analysisMethod=analysis.method)
+ dbWriteTable(con, "project", dat, row.names=FALSE, append=TRUE)
+ res <- dbGetQuery(con, str_c("SELECT id FROM project ",
+ "WHERE name=", sq(project.name)))
+ return(res$id)
+}
+
gen.clear.ml.id <- function(conf, ml) {
return(gen.clear.ml.id(conf$con, ml, conf$pid))
}
--
2.1.4


Other related posts: