void MysqlThread::RunThread(IThreadHandle *pHandle) { DatabaseInfo info; info.database = m_db.chars(); info.pass = ""; info.user = ""; info.host = ""; info.port = 0; float save_time = m_qrInfo.queue_time; memset(&m_qrInfo, 0, sizeof(m_qrInfo)); m_qrInfo.queue_time = save_time; IDatabase *pDatabase = g_Sqlite.Connect(&info, &m_qrInfo.amxinfo.info.errorcode, m_qrInfo.amxinfo.error, 254); IQuery *pQuery = NULL; if (!pDatabase) { m_qrInfo.connect_success = false; m_qrInfo.query_success = false; } else { m_qrInfo.connect_success = true; pQuery = pDatabase->PrepareQuery(m_query.chars()); if (!pQuery->Execute2(&m_qrInfo.amxinfo.info, m_qrInfo.amxinfo.error, 254)) { m_qrInfo.query_success = false; } else { m_qrInfo.query_success = true; } } if (m_qrInfo.query_success && m_qrInfo.amxinfo.info.rs) { m_atomicResult.CopyFrom(m_qrInfo.amxinfo.info.rs); m_qrInfo.amxinfo.info.rs = &m_atomicResult; } if (pQuery) { m_qrInfo.amxinfo.pQuery = pQuery; } else { m_qrInfo.amxinfo.opt_ptr = new char[m_query.length() + 1]; strcpy(m_qrInfo.amxinfo.opt_ptr, m_query.chars()); } if (pDatabase) { pDatabase->FreeHandle(); pDatabase = NULL; } }
void FreeDatabase(void *p, unsigned int num) { IDatabase *db = (IDatabase *)p; db->FreeHandle(); }