diff --git a/database/database.cpp b/database/database.cpp index 52d7738200..0e88bc0704 100644 --- a/database/database.cpp +++ b/database/database.cpp @@ -14,6 +14,15 @@ Database::~Database() { } +bool Database::getNull(const char* colName) +{ + int index; + if(getColNumber(colName,&index)) + { + return(getNull(index)); + } + return true; +} char* Database::getStr(const char* colName,std::string& retStr) { @@ -134,4 +143,14 @@ char* Database::getSingleDBValueStr(const char* sql,std::string& retStr) ret=0; } return(ret); -} \ No newline at end of file +} + +std::string Database::escape(const std::string strValue) +{ + std::string strReturn; + + escape(reinterpret_cast(strValue.c_str()), strValue.size(), strReturn); + + return strReturn; +} +// vim:ts=4 diff --git a/database/database.h b/database/database.h index d06ac10c89..ea0dc083f6 100644 --- a/database/database.h +++ b/database/database.h @@ -30,7 +30,8 @@ public: std::string& getPass(){ return(mDBPass); } virtual void escape(const unsigned char* start,int size,std::string& retStr)=0; - + std::string escape(const std::string strValue); + // returns true if the query went ok virtual bool executeSQL(const char* sql, bool fail_okay=false)=0; @@ -47,6 +48,7 @@ public: virtual bool getNextRow()=0; // get Data from the current row + bool getNull(const char* colName); char* getStr(const char* colName,std::string& retStr); int32 getInt(const char* colName); float getFloat(const char* colName); @@ -55,6 +57,7 @@ public: int getBinary(const char* colName,unsigned char* buf,int maxSize); uint64 getBigInt(const char* colName); + virtual bool getNull(int colIndex)=0; virtual char* getStr(int colIndex,std::string& retStr)=0; virtual int32 getInt(int colIndex)=0; virtual float getFloat(int colIndex)=0;