extensions/clientprefs/query.cpp
changeset 2048 2454ff4d6afb
parent 2009 1a1236dfdbb1
child 2131 cbad21fc7626
     1.1 --- a/extensions/clientprefs/query.cpp	Mon May 12 02:05:57 2008 +0000
     1.2 +++ b/extensions/clientprefs/query.cpp	Mon May 12 08:06:47 2008 +0000
     1.3 @@ -47,28 +47,34 @@
     1.4  			g_CookieManager.ClientConnectCallback(m_client, m_pQuery);
     1.5  			break;
     1.6  		case Query_InsertData:
     1.7 -			g_pSM->LogMessage(myself, "Inserted data into table");
     1.8  			//No specific handling
     1.9  			break;
    1.10 +		case Query_SelectId:
    1.11 +			g_CookieManager.SelectIdCallback(pCookie, m_pQuery);
    1.12 +			break;
    1.13  		default:
    1.14  			break;
    1.15  		}
    1.16 +
    1.17 +		m_pQuery->Destroy();
    1.18  	}
    1.19  	else
    1.20  	{
    1.21 -		g_pSM->LogError(myself,"Failed SQL Query Error: \"%s\"- Ref Id: %i, Client num: %i",error ,m_type, m_client);
    1.22 +		g_pSM->LogError(myself,"Failed SQL Query, Error: \"%s\" (Query id %i - client %i)", error, m_type, m_client);
    1.23  	}
    1.24  }
    1.25  
    1.26  void TQueryOp::RunThreadPart()
    1.27  {
    1.28  	m_pDatabase->LockForFullAtomicOperation();
    1.29 -	if (!m_pQuery->Execute())
    1.30 +	m_pQuery = m_pDatabase->DoQuery(m_Query.c_str());
    1.31 +
    1.32 +	if (!m_pQuery)
    1.33  	{
    1.34 -		g_pSM->LogError(myself, m_pQuery->GetError());
    1.35 +		g_pSM->LogError(myself, "Failed SQL Query, Error: \"%s\" (Query id %i - client %i)", m_pDatabase->GetError(), m_type, m_client);
    1.36  	}
    1.37  
    1.38 -	m_insertId = m_pQuery->GetInsertID();
    1.39 +	m_insertId = g_ClientPrefs.Database->GetInsertID();
    1.40  
    1.41  	m_pDatabase->UnlockFromFullAtomicOperation();
    1.42  }
    1.43 @@ -86,20 +92,20 @@
    1.44  	delete this;
    1.45  }
    1.46  
    1.47 -TQueryOp::TQueryOp(IDatabase *db, IPreparedQuery *query, enum querytype type, int client)
    1.48 +TQueryOp::TQueryOp(IDatabase *db, const char *query, enum querytype type, int client)
    1.49  {
    1.50  	m_pDatabase = db;
    1.51 -	m_pQuery = query;
    1.52 +	m_Query = query;
    1.53  	m_type = type;
    1.54  	m_client = client;
    1.55  
    1.56  	m_pDatabase->IncReferenceCount();
    1.57  }
    1.58  
    1.59 -TQueryOp::TQueryOp(IDatabase *db, IPreparedQuery *query, enum querytype type, Cookie *cookie)
    1.60 +TQueryOp::TQueryOp(IDatabase *db, const char *query, enum querytype type, Cookie *cookie)
    1.61  {
    1.62  	m_pDatabase = db;
    1.63 -	m_pQuery = query;
    1.64 +	m_Query = query;
    1.65  	m_type = type;
    1.66  	pCookie = cookie;
    1.67