version 0.1.3
[fms.git] / src / db / sqlite3db.cpp
index 809fc68..1b63715 100644 (file)
@@ -30,7 +30,8 @@ const bool DB::Close()
 {\r
        if(IsOpen())\r
        {\r
-               ZThread::Guard<ZThread::Mutex> g(m_mutex);\r
+               //ZThread::Guard<ZThread::Mutex> g(m_mutex);\r
+               PThread::Guard g(m_mutex);\r
                m_lastresult=sqlite3_close(m_db);\r
                if(m_lastresult==SQLITE_OK)\r
                {\r
@@ -52,7 +53,8 @@ const bool DB::Execute(const std::string &sql)
 {\r
        if(IsOpen())\r
        {\r
-               ZThread::Guard<ZThread::Mutex> g(m_mutex);\r
+               //ZThread::Guard<ZThread::Mutex> g(m_mutex);\r
+               PThread::Guard g(m_mutex);\r
                m_lastresult=sqlite3_exec(m_db,sql.c_str(),NULL,NULL,NULL);\r
                if(m_lastresult==SQLITE_OK)\r
                {\r
@@ -73,7 +75,8 @@ const bool DB::ExecuteInsert(const std::string &sql, long &insertid)
 {\r
        if(IsOpen())\r
        {\r
-               ZThread::Guard<ZThread::Mutex> g(m_mutex);\r
+               //ZThread::Guard<ZThread::Mutex> g(m_mutex);\r
+               PThread::Guard g(m_mutex);\r
                m_lastresult=sqlite3_exec(m_db,sql.c_str(),NULL,NULL,NULL);\r
                if(m_lastresult==SQLITE_OK)\r
                {\r
@@ -95,7 +98,8 @@ const int DB::GetLastError(std::string &errormessage)
 {\r
        if(IsOpen())\r
        {\r
-               ZThread::Guard<ZThread::Mutex> g(m_mutex);\r
+               //ZThread::Guard<ZThread::Mutex> g(m_mutex);\r
+               PThread::Guard g(m_mutex);\r
                int errcode=sqlite3_errcode(m_db);\r
                const char *errmsg=sqlite3_errmsg(m_db);\r
                if(errmsg)\r
@@ -118,7 +122,8 @@ void DB::Initialize()
 \r
 const bool DB::IsOpen()\r
 {\r
-       ZThread::Guard<ZThread::Mutex> g(m_mutex);\r
+       //ZThread::Guard<ZThread::Mutex> g(m_mutex);\r
+       PThread::Guard g(m_mutex);\r
        return m_db ? true : false; \r
 }\r
 \r
@@ -130,7 +135,8 @@ const bool DB::Open(const std::string &filename)
        }\r
        if(IsOpen()==false)\r
        {\r
-               ZThread::Guard<ZThread::Mutex> g(m_mutex);\r
+               //ZThread::Guard<ZThread::Mutex> g(m_mutex);\r
+               PThread::Guard g(m_mutex);\r
                m_lastresult=sqlite3_open(filename.c_str(),&m_db);\r
                if(m_lastresult==SQLITE_OK)\r
                {\r
@@ -151,7 +157,8 @@ Statement DB::Prepare(const std::string &sql)
 {\r
        if(IsOpen())\r
        {\r
-               ZThread::Guard<ZThread::Mutex> g(m_mutex);\r
+               //ZThread::Guard<ZThread::Mutex> g(m_mutex);\r
+               PThread::Guard g(m_mutex);\r
                sqlite3_stmt *statement=NULL;\r
                m_lastresult=sqlite3_prepare_v2(m_db,sql.c_str(),sql.size(),&statement,NULL);\r
                if(m_lastresult==SQLITE_OK)\r
@@ -173,7 +180,8 @@ Recordset DB::Query(const std::string &sql)
 {\r
        if(IsOpen())\r
        {\r
-               ZThread::Guard<ZThread::Mutex> g(m_mutex);\r
+               //ZThread::Guard<ZThread::Mutex> g(m_mutex);\r
+               PThread::Guard g(m_mutex);\r
                char **rs=NULL;\r
                int rows,cols;\r
                m_lastresult=sqlite3_get_table(m_db,sql.c_str(),&rs,&rows,&cols,NULL);\r
@@ -197,10 +205,15 @@ const int DB::SetBusyTimeout(const int ms)
 {\r
        if(IsOpen())\r
        {\r
-               ZThread::Guard<ZThread::Mutex> g(m_mutex);\r
+               //ZThread::Guard<ZThread::Mutex> g(m_mutex);\r
+               PThread::Guard g(m_mutex);\r
                m_lastresult=sqlite3_busy_timeout(m_db,ms);\r
                return m_lastresult;\r
        }\r
+       else\r
+       {\r
+               return SQLITE_ERROR;\r
+       }\r
 }\r
 \r
 }      // namespace\r