144 typedef char MYSQL_RES;
145 typedef char MYSQL_ROW;
147 typedef int MYSQL_FIELD;
150 #include "stdb_streams.h"
151 #include "StDbBuffer.h"
152 #include "StDbLogger.hh"
153 #include "parseXmlString.hh"
154 #include "StDbManagerImpl.hh"
155 #include "StHyperCacheManager.h"
160 #define freeze(i) str()
179 virtual unsigned NbRows () {
return mysql_num_rows(mRes);};
180 virtual unsigned NbFields () {
return mysql_num_fields(mRes);};
181 virtual void Release () {
if(mRes)mysql_free_result(mRes);mRes=0;};
182 MysqlResult &operator++() {mRow=mysql_fetch_row(mRes);
return *
this;};
194 unsigned long int mLen;
198 virtual void Input(
const unsigned long int aLen,
char *aBin)
199 {mBinData=aBin;mLen=aLen;};
211 unsigned long int mQueryLen;
216 bool mhasBinaryQuery;
223 char* mdbServerVersion;
225 std::string mSysusername;
227 unsigned int mtimeout;
235 bool isSpecialType[200];
248 virtual bool Connect(
const char *aHost,
const char *aUser,
249 const char *aPasswd,
const char *aDb,
const int aPort=0);
250 virtual bool reConnect();
252 virtual unsigned NbRows() {
254 if (m_Mgr.isActive() && m_Mgr.isValueFound()) {
return m_Mgr.getNumRows(); }
255 return mRes->NbRows();
260 virtual unsigned NbFields() {
262 if (m_Mgr.isActive() && m_Mgr.isValueFound()) {
return m_Mgr.getNumFields(); }
263 return mRes->NbFields();
268 virtual void Release() {mRes->Release();};
270 virtual char* printQuery();
274 virtual bool InputStart(
const char *aName,
StDbBuffer *aBuff,
const char* colList,
int nRows,
bool& hasBinary);
275 virtual bool InputRow(
StDbBuffer* aBuff,
int row);
276 virtual bool InputEnd();
279 virtual bool Input(
const char *aName,
StDbBuffer *aBuff);
282 MysqlDb &operator<<(
const char *c);
283 MysqlDb &operator<<(
const string s);
286 MysqlDb &operator<<(
const short aq);
287 MysqlDb &operator<<(
const unsigned short aq);
288 MysqlDb &operator<<(
const int aq);
289 MysqlDb &operator<<(
const unsigned int aq);
290 MysqlDb &operator<<(
const long long aq);
291 MysqlDb &operator<<(
const float aq);
292 MysqlDb &operator<<(
const double aq);
294 char **DecodeStrArray(
char* strinput ,
int &aLen) ;
295 char* CodeStrArray(
char** strarr ,
int aLen);
296 virtual int GetLastInsertID(){
return (
int)mysql_insert_id(&mData);}
297 virtual bool QueryStatus() {
return mqueryState; }
298 virtual bool checkForTable(
const char* tableName);
299 virtual void Close();
300 virtual bool IsConnected() {
return mhasConnected; }
301 virtual bool setDefaultDb(
const char* dbName);
306 virtual void RazQuery() ;
307 virtual bool ExecQuery();
321 inline void MysqlDb::Close(){
322 if(mhasConnected)mysql_close(&mData);
326 inline MysqlDb &MysqlDb::operator<<(
const string s){
327 return *
this<<s.c_str();
330 inline MysqlDb &MysqlDb::operator<<(
const short aq){
332 return *
this<<ts.str();
335 inline MysqlDb &MysqlDb::operator<<(
const unsigned short aq){
337 return *
this<<ts.str();
340 inline MysqlDb &MysqlDb::operator<<(
const int aq){
342 return *
this<<ts.str();
345 inline MysqlDb &MysqlDb::operator<<(
const unsigned int aq){
347 return *
this<<ts.str();
350 inline MysqlDb &MysqlDb::operator<<(
const long long aq){
352 return *
this<<ts.str();
355 inline MysqlDb &MysqlDb::operator<<(
const float aq){
357 return *
this<<ts.str();
360 inline MysqlDb &MysqlDb::operator<<(
const double aq){
362 return *
this<<ts.str();
366 extern const MysqlBin *Binary(
const unsigned long int aLen,
const float *aBin);