From ecb29918812fe5ba5c417dd345c2cd7d2d50d727 Mon Sep 17 00:00:00 2001 From: Julien BLACHE Date: Sun, 22 Nov 2009 12:34:37 +0100 Subject: [PATCH] Add db_pl_fetch_bytitlepath --- src/db.c | 24 ++++++++++++++++++++++++ src/db.h | 3 +++ 2 files changed, 27 insertions(+) diff --git a/src/db.c b/src/db.c index 16a97539..67c62d51 100644 --- a/src/db.c +++ b/src/db.c @@ -1688,6 +1688,30 @@ db_pl_fetch_bypath(char *path) #undef Q_TMPL } +struct playlist_info * +db_pl_fetch_bytitlepath(char *title, char *path) +{ +#define Q_TMPL "SELECT * FROM playlists WHERE title = '%q' AND path = '%q';" + struct playlist_info *pli; + char *query; + + query = sqlite3_mprintf(Q_TMPL, title, path); + if (!query) + { + DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); + + return NULL; + } + + pli = db_pl_fetch_byquery(query); + + sqlite3_free(query); + + return pli; + +#undef Q_TMPL +} + int db_pl_add(char *title, char *path, int *id) { diff --git a/src/db.h b/src/db.h index 8ef4cfb8..ef1f990f 100644 --- a/src/db.h +++ b/src/db.h @@ -275,6 +275,9 @@ db_pl_ping(int id); struct playlist_info * db_pl_fetch_bypath(char *path); +struct playlist_info * +db_pl_fetch_bytitlepath(char *title, char *path); + int db_pl_add(char *title, char *path, int *id);