2 * Copyright (C) 2009 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 * Somer helper functions to get some fields from the sqlite database.
29 static char * talker_email_query = "select email from auth_user,"
30 "events_speaker where auth_user.id = events_speaker.user_id "
31 "and events_speaker.id = %d;";
32 static char * talker_name_query = "select first_name from auth_user,"
33 "events_speaker where auth_user.id = events_speaker.user_id "
34 "and events_speaker.id = %d;";
36 static char * get_talker_userfield(sqlite3 *db, char *query, int id)
42 r = asprintf(&s, query, id);
43 r = sqlite3_prepare_v2(db, s, r, &stmt, NULL);
45 while (sqlite3_step(stmt) == SQLITE_ROW) {
48 email = strdup(sqlite3_column_text(stmt, 0));
50 sqlite3_finalize(stmt);
54 char * get_talker_email(sqlite3 *db, int id)
56 return get_talker_userfield(db, talker_email_query, id);
59 char * get_talker_name(sqlite3 *db, int id)
61 return get_talker_userfield(db, talker_name_query, id);