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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
diff -Naur verlihub-orig/src/cdbconf.cpp verlihub/src/cdbconf.cpp
--- verlihub-orig/src/cdbconf.cpp 2008-10-18 18:43:43.000000000 +0400
+++ verlihub/src/cdbconf.cpp 2008-10-18 18:43:09.000000000 +0400
@@ -22,6 +22,7 @@
Add("lang_name",lang_name,string("lang_en"));
Add("allow_exec",allow_exec, false);
Add("allow_exec_mod",allow_exec_mod, true);
+ Add("db_charset",db_charset,string("utf8"));
Load();
}
diff -Naur verlihub-orig/src/cdbconf.h verlihub/src/cdbconf.h
--- verlihub-orig/src/cdbconf.h 2008-10-18 18:43:43.000000000 +0400
+++ verlihub/src/cdbconf.h 2008-10-18 18:43:09.000000000 +0400
@@ -31,6 +31,7 @@
string db_user;
string db_pass;
string db_data;
+ string db_charset;
string config_name;
string lang_name;
bool allow_exec;
diff -Naur verlihub-orig/src/cmysql.cpp verlihub/src/cmysql.cpp
--- verlihub-orig/src/cmysql.cpp 2008-10-18 18:43:43.000000000 +0400
+++ verlihub/src/cmysql.cpp 2008-10-18 18:43:09.000000000 +0400
@@ -19,10 +19,10 @@
/*!
\fn nMySQL::cMySQL::cMySQL(string&host,string&user,string&pass,string&data)
*/
-cMySQL::cMySQL(string&host,string&user,string&pass,string&data) : cObj("cMySQL")
+cMySQL::cMySQL(string&host,string&user,string&pass,string&data,string&charset) : cObj("cMySQL")
{
Init();
- if(!Connect(host,user,pass,data))
+ if(!Connect(host,user,pass,data,charset))
{
throw "Mysql connection error.";
}
@@ -40,12 +40,13 @@
if(!mDBHandle) Error(0, string("Can't init mysql structure :(.: "));
}
-bool cMySQL::Connect(string &host, string &user, string &pass, string &data)
+bool cMySQL::Connect(string &host, string &user, string &pass, string &data, string &charset)
{
if(Log(1)) LogStream() << "Connecting to mysql server: "
- << user << "@" << host << "/" << data << endl;
+ << user << "@" << host << "/" << data << "with charset " << charset << endl;
mysql_options(mDBHandle,MYSQL_OPT_COMPRESS,0);
+ mysql_options(mDBHandle,MYSQL_SET_CHARSET_NAME,charset.c_str());
if(!mysql_real_connect(
mDBHandle,
diff -Naur verlihub-orig/src/cmysql.h verlihub/src/cmysql.h
--- verlihub-orig/src/cmysql.h 2008-10-18 18:43:43.000000000 +0400
+++ verlihub/src/cmysql.h 2008-10-18 18:43:09.000000000 +0400
@@ -34,10 +34,10 @@
friend class cQuery;
public:
cMySQL();
- cMySQL(string&host,string&user,string&pass,string&data);
+ cMySQL(string&host,string&user,string&pass,string&data,string&charset);
~cMySQL();
void Init();
- bool Connect(string &host, string &user, string &passwd, string &db);
+ bool Connect(string &host, string &user, string &passwd, string &db, string &charset);
public: void Error(int level, string text);
private:
diff -Naur verlihub-orig/src/cserverdc.cpp verlihub/src/cserverdc.cpp
--- verlihub-orig/src/cserverdc.cpp 2008-10-18 18:43:43.000000000 +0400
+++ verlihub/src/cserverdc.cpp 2008-10-18 18:43:09.000000000 +0400
@@ -72,7 +72,8 @@
mDBConf.db_host,
mDBConf.db_user,
mDBConf.db_pass,
- mDBConf.db_data), // connect to mysql
+ mDBConf.db_data,
+ mDBConf.db_charset), // connect to mysql
mC(*this), // create the config object
mL(*this),
mSetupList(mMySQL),
|