diff options
author | David Sommerseth <dazo@users.sourceforge.net> | 2008-12-20 18:14:36 +0100 |
---|---|---|
committer | David Sommerseth <dazo@users.sourceforge.net> | 2008-12-20 18:14:36 +0100 |
commit | 1f4d314e1cd5f27c053682a9aedc494c22b6e4c8 (patch) | |
tree | 1503f1428b07bff258a6baa233fe1a68a3daa85a /database | |
parent | 12cf780e59073fcc81cb72174884d2affe6b460e (diff) | |
download | eurephia-1f4d314e1cd5f27c053682a9aedc494c22b6e4c8.tar.gz eurephia-1f4d314e1cd5f27c053682a9aedc494c22b6e4c8.tar.xz eurephia-1f4d314e1cd5f27c053682a9aedc494c22b6e4c8.zip |
sqlite3 - Added sortkeys as argument to sqlite_query_mapped(...)
The last argument to the function can contain a list over field names
which will be used in the ORDER BY clause when doing SELECT queries.
Diffstat (limited to 'database')
-rw-r--r-- | database/sqlite/administration.c | 12 | ||||
-rw-r--r-- | database/sqlite/sqlite.c | 8 | ||||
-rw-r--r-- | database/sqlite/sqlite.h | 2 |
3 files changed, 14 insertions, 8 deletions
diff --git a/database/sqlite/administration.c b/database/sqlite/administration.c index 44f9bc1..3f8c286 100644 --- a/database/sqlite/administration.c +++ b/database/sqlite/administration.c @@ -451,7 +451,7 @@ xmlDoc *eDBadminGetUserInfo(eurephiaCTX *ctx, int getInfo, xmlDoc *srch) { " WHERE sessionstatus = 2" " GROUP BY uid) os" " ON (os.uid = u.uid)", - NULL, uinfo_map); + NULL, uinfo_map, NULL); if( uinf == NULL ) { eurephia_log(ctx, LOG_ERROR, 0, "Error querying the database for a user"); @@ -702,7 +702,7 @@ int eDBadminAddUser(eurephiaCTX *ctx, xmlDoc *usrinf) { assert( usrinf_map != NULL ); // Register the user - res = sqlite_query_mapped(ctx, SQL_INSERT, "INSERT INTO openvpn_users", usrinf_map, NULL); + res = sqlite_query_mapped(ctx, SQL_INSERT, "INSERT INTO openvpn_users", usrinf_map, NULL, NULL); if( res == NULL ) { eurephia_log(ctx, LOG_FATAL, 0, "Could not register the new user account"); rc = 0; @@ -764,7 +764,7 @@ int eDBadminUpdateUser(eurephiaCTX *ctx, const int uid, xmlDoc *usrinf) { assert( srch_map != NULL ); // UPDATE the database - uinf = sqlite_query_mapped(ctx, SQL_UPDATE, "UPDATE openvpn_users", value_map, srch_map); + uinf = sqlite_query_mapped(ctx, SQL_UPDATE, "UPDATE openvpn_users", value_map, srch_map, NULL); if( uinf == NULL ) { eurephia_log(ctx, LOG_ERROR, 0, "Error querying the database for a user"); @@ -827,6 +827,8 @@ xmlDoc *eDBadminGetCertificateList(eurephiaCTX *ctx, const char *sortkeys) { return NULL; } + + xmlDoc *eDBadminGetCertificateInfo(eurephiaCTX *ctx, xmlDoc *srchkey) { return NULL; } @@ -871,7 +873,7 @@ int eDBadminAddCertificate(eurephiaCTX *ctx, xmlDoc *certxml) { assert( crtinf_map != NULL ); // Register the certificate - res = sqlite_query_mapped(ctx, SQL_INSERT, "INSERT INTO openvpn_certificates", crtinf_map, NULL); + res = sqlite_query_mapped(ctx, SQL_INSERT, "INSERT INTO openvpn_certificates", crtinf_map, NULL, NULL); if( res == NULL ) { eurephia_log(ctx, LOG_FATAL, 0, "Could not register the certificate"); rc = 0; @@ -925,7 +927,7 @@ int eDBadminDeleteCertificate(eurephiaCTX *ctx, xmlDoc *certxml) { assert( crtinf_map != NULL ); // Register the certificate - res = sqlite_query_mapped(ctx, SQL_DELETE, "DELETE FROM openvpn_certificates", NULL, crtinf_map); + res = sqlite_query_mapped(ctx, SQL_DELETE, "DELETE FROM openvpn_certificates", NULL, crtinf_map, NULL); if( res == NULL ) { eurephia_log(ctx, LOG_FATAL, 0, "Could not complete the delete certificate request"); rc = 0; diff --git a/database/sqlite/sqlite.c b/database/sqlite/sqlite.c index 7f9f7fc..6b0cd72 100644 --- a/database/sqlite/sqlite.c +++ b/database/sqlite/sqlite.c @@ -386,7 +386,7 @@ char *_build_sqlpart(int btyp, eDBfieldMap *map) { dbresult *sqlite_query_mapped(eurephiaCTX *ctx, SQLqueryType qType, const char *sqlstub, - eDBfieldMap *valMap, eDBfieldMap *whereMap) + eDBfieldMap *valMap, eDBfieldMap *whereMap, const char *sortkeys) { dbresult *res = NULL; char *tmp1 = NULL, *tmp2 = NULL; @@ -399,7 +399,11 @@ dbresult *sqlite_query_mapped(eurephiaCTX *ctx, SQLqueryType qType, const char * case SQL_DELETE: if( whereMap != NULL ) { tmp1 = _build_sqlpart(btWHERE, whereMap); - res = sqlite_query(ctx, "%s WHERE %s", sqlstub, tmp1); + if( sortkeys == NULL ) { + res = sqlite_query(ctx, "%s WHERE %s", sqlstub, tmp1); + } else { + res = sqlite_query(ctx, "%s WHERE %s ORDER BY %s", sqlstub, tmp1, sortkeys); + } free_nullsafe(tmp1); } break; diff --git a/database/sqlite/sqlite.h b/database/sqlite/sqlite.h index 4ffbfd5..10f8fd4 100644 --- a/database/sqlite/sqlite.h +++ b/database/sqlite/sqlite.h @@ -72,7 +72,7 @@ typedef enum _SQLqueryType { SQL_SELECT, SQL_INSERT, SQL_UPDATE, SQL_DELETE } SQ void _sqlite_free_results(dbresult *); dbresult *sqlite_query(eurephiaCTX *ctx, const char *, ...); dbresult *sqlite_query_mapped(eurephiaCTX *ctx, SQLqueryType type, const char *sqlstub, - eDBfieldMap *valMap, eDBfieldMap *whereMap); + eDBfieldMap *valMap, eDBfieldMap *whereMap, const char *sortkeys); char *sqlite_get_value(dbresult *res, int, int); #ifdef HAVE_LIBXML2 xmlNodePtr sqlite_xml_value(xmlNodePtr node, xmlFieldType xmltyp, char *name, dbresult *res, int row, int col); |