-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGenericKey.cpp
68 lines (56 loc) · 1.54 KB
/
GenericKey.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// wxWindows includes
#include <wx/string.h>
#include <wx/arrstr.h>
#include <wx/dynarray.h>
// Statsgen includes
#include "GenericKey.h"
#include "GlobalStatistics.h"
GenericKey::GenericKey()
{
}
GenericKey::~GenericKey()
{
}
wxString GenericKey::SQLCreateTable(char *tableName)
{
wxString SQL;
SQL.Printf("create table %s"
"("
"idx integer,"
"%s,"
"%s,"
"%s"
")",
tableName,
StatsgenDatabase::StringFieldDefinition("id","generickeyid",FIELD_WIDTH_KEY_ID).GetData(),
StatsgenDatabase::StringFieldDefinition("realname","generickeyname",FIELD_WIDTH_KEY_REALNAME).GetData(),
StatsgenDatabase::StringFieldDefinition("image","generickeyimage",FIELD_WIDTH_KEY_IMAGE).GetData()
);
return SQL;
}
bool GenericKey::WriteToDatabase(char *tableName,int keyIndex)
{
wxString SQL;
bool retVal=true;
wxString image;
wxString realName="";
wxString configKey="";
if (id.Length()>0)
{
configKey.Printf("/Images/%s_%s",tableName,id.GetData());
globalStatistics.configData.ReadTextValue(configKey,&image,"");
configKey.Printf("/RealNames/%s_%s",tableName,id.GetData());
globalStatistics.configData.ReadTextValue(configKey,&realName,(char *)id.GetData());
}
SQL.Printf("insert into %s"
"(idx,id,realname,image)"
"values"
"('%d','%s','%s','%s')",
tableName,
keyIndex,
StatsgenDatabase::SafeForInsert(id).GetData(),
StatsgenDatabase::SafeForInsert(realName).GetData(),
StatsgenDatabase::SafeForInsert(image).GetData());
globalStatistics.statsgenDatabase.SimpleExecute(SQL);
return retVal;
}