diff options
Diffstat (limited to 'src/modules/UserBackendMysql/UserBackendMysql.h')
-rw-r--r-- | src/modules/UserBackendMysql/UserBackendMysql.h | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/src/modules/UserBackendMysql/UserBackendMysql.h b/src/modules/UserBackendMysql/UserBackendMysql.h index 52a134a..25c3837 100644 --- a/src/modules/UserBackendMysql/UserBackendMysql.h +++ b/src/modules/UserBackendMysql/UserBackendMysql.h @@ -34,8 +34,54 @@ namespace Mad { namespace Modules { namespace UserBackendMysql { -class UserBackendMysql : public Common::UserBackend, private Core::Configurable { +class UserBackendMysql : public Common::UserBackend, private Core::Configurable, private boost::noncopyable { private: + class Result : private boost::noncopyable { + private: + MYSQL_RES *result; + + unsigned int mysqlErrno; + const char *error; + + public: + Result(MYSQL *mysql) { + result = mysql_store_result(mysql); + + mysqlErrno = mysql_errno(mysql); + error = mysql_error(mysql); + } + + ~Result() { + if(result) { + mysql_free_result(result); + } + } + + operator bool() const { + return result; + } + + unsigned int getErrno() const { + return mysqlErrno; + } + + const char* getError() const { + return error; + } + + unsigned int getFieldNumber() const { + return mysql_num_fields(result); + } + + my_ulonglong getRowNumber() const { + return mysql_num_rows(result); + } + + MYSQL_ROW getNextRow() { + return mysql_fetch_row(result); + } + }; + Common::Application *application; std::string host, username, passwd, db, unixSocket; @@ -46,6 +92,7 @@ class UserBackendMysql : public Common::UserBackend, private Core::Configurable std::string queryUserById, queryUserByName; std::string queryGroupById, queryGroupByName; std::string queryUserGroupTable; + std::string queryAddUser; MYSQL *mysql; @@ -69,6 +116,8 @@ class UserBackendMysql : public Common::UserBackend, private Core::Configurable virtual boost::shared_ptr<const std::multimap<unsigned long, unsigned long> > getFullUserGroupList(boost::posix_time::ptime *timestamp) throw(Core::Exception); + virtual void addUser(const Common::UserInfo &userInfo) throw(Core::Exception); + public: UserBackendMysql(Common::Application *application0) : application(application0), port(0), mysql(0), lastUpdate(boost::posix_time::microsec_clock::universal_time()) { application->getConfigManager()->registerConfigurable(this); |