diff options
author | Huynh Tran <nthuynh75@gmail.com> | 2005-06-19 07:10:58 +0000 |
---|---|---|
committer | Huynh Tran <nthuynh75@gmail.com> | 2005-06-19 07:10:58 +0000 |
commit | ee3b57e273e4b0437aaaa23ba6addb68e4c4fcca (patch) | |
tree | a6218c7fc44684bd5ed3ee8683c6633767dc9de0 /src/dalstorage.cpp | |
parent | 514b591061df787a840a560b2e99285eca527f2f (diff) | |
download | manaserv-ee3b57e273e4b0437aaaa23ba6addb68e4c4fcca.tar.gz manaserv-ee3b57e273e4b0437aaaa23ba6addb68e4c4fcca.tar.bz2 manaserv-ee3b57e273e4b0437aaaa23ba6addb68e4c4fcca.tar.xz manaserv-ee3b57e273e4b0437aaaa23ba6addb68e4c4fcca.zip |
Reworked Storage APIs and reordered operations in DALStorage to match those of Storage.
Diffstat (limited to 'src/dalstorage.cpp')
-rw-r--r-- | src/dalstorage.cpp | 96 |
1 files changed, 53 insertions, 43 deletions
diff --git a/src/dalstorage.cpp b/src/dalstorage.cpp index 73e4f101..1d818fb0 100644 --- a/src/dalstorage.cpp +++ b/src/dalstorage.cpp @@ -110,49 +110,6 @@ DALStorage::~DALStorage() /** - * Save changes to the database permanently. - */ -void -DALStorage::flush(void) -{ - // this feature is not currently provided by DAL. -} - - -/** - * Get the number of Accounts saved in database. - */ -unsigned int -DALStorage::getAccountCount(void) -{ - // connect to the database (if not connected yet). - connect(); - - using namespace dal; - - unsigned int value = 0; - - try { - // query the database. - std::string sql("select count(*) from "); - sql += ACCOUNTS_TBL_NAME; - sql += ";"; - const RecordSet& rs = mDb->execSql(sql); - - // specialize the string_to functor to convert - // a string to an unsigned int. - string_to<unsigned int> toUint; - - value = toUint(rs(0, 0)); - } catch (const DbSqlQueryExecFailure& f) { - std::cout << "Get accounts count failed :'(" << std::endl; - } - - return value; -} - - -/** * Get an account by user name. */ Account* @@ -244,6 +201,59 @@ DALStorage::getAccount(const std::string& userName) /** + * Add a new account. + */ +void +DALStorage::addAccount(const Account* account) +{ + // TODO +} + + +/** + * Save changes to the database permanently. + */ +void +DALStorage::flush(void) +{ + // this feature is not currently provided by DAL. +} + + +/** + * Get the number of Accounts saved in database. + */ +unsigned int +DALStorage::getAccountCount(void) +{ + // connect to the database (if not connected yet). + connect(); + + using namespace dal; + + unsigned int value = 0; + + try { + // query the database. + std::string sql("select count(*) from "); + sql += ACCOUNTS_TBL_NAME; + sql += ";"; + const RecordSet& rs = mDb->execSql(sql); + + // specialize the string_to functor to convert + // a string to an unsigned int. + string_to<unsigned int> toUint; + + value = toUint(rs(0, 0)); + } catch (const DbSqlQueryExecFailure& f) { + std::cout << "Get accounts count failed :'(" << std::endl; + } + + return value; +} + + +/** * Connect to the database and initialize it if necessary. */ void |