allow fields select in dbhelpder

This commit is contained in:
Xuan Sang LE 2018-03-06 21:29:04 +01:00
parent fc2daeb620
commit f251e0ac14
2 changed files with 4 additions and 4 deletions

View File

@ -132,10 +132,10 @@ dbrecord dball(sqlite3* db,const char* table)
{
return dbselect(db,table,"1=%d",1);
}
dbrecord dbselect(sqlite3* db, const char* table,const char* fstring,...)
dbrecord dbselect(sqlite3* db, const char* table, const char* fname,const char* fstring,...)
{
char* sql;
char* prefix = "SELECT * FROM %s WHERE %s";
char* prefix = "SELECT (%s) FROM %s WHERE %s";
char* cond;
va_list arguments;
int dlen;
@ -149,7 +149,7 @@ dbrecord dbselect(sqlite3* db, const char* table,const char* fstring,...)
va_start(arguments, fstring);
vsnprintf(cond, dlen, fstring, arguments);
va_end(arguments);
sql = __s(prefix,table,cond);
sql = __s(prefix, fname,table,cond);
if(sqlite3_prepare_v2(db, sql, -1, &statement, 0) == SQLITE_OK)
{

View File

@ -22,7 +22,7 @@ int dbquery(sqlite3*,const char*, int (*)());
int dbinsert(sqlite3*,const char*,const dbfield);
int hastable(sqlite3*,const char*);
int dbupdate(sqlite3*,const char*,const dbfield,const char*,...);
dbrecord dbselect(sqlite3*, const char*,const char*,...);
dbrecord dbselect(sqlite3*, const char*, const char*,const char*,...);
dbrecord dball(sqlite3*,const char*);
int dbdelete(sqlite3*,const char*,const char*,...);
dbfield __field();