4 //#include <zthread/Singleton.h>
\r
5 //#include <zthread/Mutex.h>
\r
8 #include "../../pthreadwrapper/singleton.h"
\r
9 #include "../../pthreadwrapper/mutex.h"
\r
11 #include "../sqlite3db.h"
\r
16 class DB:public PThread::Singleton<DB>
\r
20 DB(std::string filename);
\r
23 const bool Open(const std::string &filename);
\r
26 const int GetLastResult() { return m_lastresult; } // gets result of last action taken - standard sqlite3 return codes
\r
27 const int GetLastError(std::string &errormessage); // gets last error of this database
\r
29 const bool IsOpen();
\r
31 const bool Execute(const std::string &sql); // executes a statement returing true if successful
\r
32 const bool ExecuteInsert(const std::string &sql, long &insertid); // call when inserting data and the insertid of the row inserted is needed, otherwise Execute can be called if the row id is not needed
\r
33 Recordset Query(const std::string &sql); // executes a statement returning a recordset
\r
34 Statement Prepare(const std::string &sql); // prepares a statement returning the statement object
\r
36 const int SetBusyTimeout(const int ms); // sets busy timeout in ms. SQLite will wait for a lock up to this many ms before returning SQLITE_BUSY
\r
38 sqlite3 *GetDB() { return m_db; }
\r
40 PThread::Mutex m_mutex; // public so that recordset and statment can lock this mutex themselves
\r
51 #endif // _sqlite3db_
\r