26 #include <BaseString.hpp>
27 #include <Properties.hpp>
32 #define DIE_UNLESS(expr) \
33 ((void) ((expr) ? 0 : (Die(__FILE__, __LINE__, #expr), 0)))
35 Die(__FILE__, __LINE__, #expr)
36 #define myerror(msg) printError(msg)
37 #define mysterror(stmt, msg) printStError(stmt, msg)
38 #define CheckStmt(stmt) \
42 DIE_UNLESS(stmt != 0); \
45 #define check_execute(stmt, r) \
48 mysterror(stmt, NULL); \
57 bool get_row(
int row_num);
70 const char* column(
const char* col_name);
71 uint columnAsInt(
const char* col_name);
72 unsigned long long columnAsLong(
const char* col_name);
74 unsigned long long insertId();
75 unsigned long long affectedRows();
78 const char* mysqlError();
79 const char* mysqlSqlstate();
82 uint get_int(
const char*
name);
83 unsigned long long get_long(
const char* name);
84 const char* get_string(
const char* name);
96 DbUtil(
const char* dbname =
"mysql",
97 const char* suffix = NULL);
100 bool doQuery(
const char*
query);
110 bool waitConnected(
int timeout = 120);
112 bool databaseLogin(
const char * host,
114 const char * password,
119 const char * getDbName() {
return m_dbname.
c_str();};
120 const char * getUser() {
return m_user.
c_str();};
121 const char * getPassword(){
return m_pass.
c_str();};
122 const char * getHost() {
return m_host.
c_str();};
123 const char * getSocket() {
return m_socket.
c_str();};
124 const char * getServerType(){
return mysql_get_server_info(m_mysql);};
125 const char * getError();
127 MYSQL * getMysql(){
return m_mysql;};
130 void databaseLogout();
131 void mysqlCloseStmHandle(
MYSQL_STMT *my_stmt);
136 bool selectDb(
const char *);
138 int getErrorNumber();
139 const char* last_error()
const {
return m_last_error.
c_str(); }
140 int last_errno()
const {
return m_last_errno; }
142 unsigned long long selectCountTable(
const char *
table);
144 void silent() { m_silent=
true; };
148 bool runQuery(
const char*
query,
177 void clear_error(
void) { m_last_errno= 0; m_last_error.
clear(); }
179 void setDbName(
const char *
name){m_dbname.
assign(name);};
180 void setUser(
const char * user_name){m_user.
assign(user_name);};
181 void setPassword(
const char * password){m_pass.
assign(password);};
182 void setHost(
const char * system){m_host.
assign(system);};
183 void setPort(
unsigned int portIn){m_port=portIn;};
184 void setSocket(
const char * sockIn){m_socket.
assign(sockIn);};
185 void printError(
const char *
msg);
187 void die(
const char *
file,
int line,
const char *expr);