summaryrefslogtreecommitdiff
path: root/plugins/Dbx_sqlite/src/utils.cpp
blob: 89f03b6d93c78904a273a4b71be7044b14f54f25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "stdafx.h"

void logError(int rc, const char *szFile, int line)
{
	switch (rc) {
	case SQLITE_OK:
	case SQLITE_ROW:
	case SQLITE_DONE:
		return;
	}

	_ASSERT(rc == 0);
	Netlib_Logf(0, "SQLITE error %d (%s, %d)", rc, szFile, line);
}

/////////////////////////////////////////////////////////////////////////////////////////

sqlite3_stmt* CDbxSQLite::InitQuery(const char *szQuery, CQuery &stmt)
{
	if (stmt.pQuery == nullptr) 
		sqlite3_prepare_v3(m_db, szQuery, -1, SQLITE_PREPARE_PERSISTENT, &stmt.pQuery, nullptr);

	return stmt.pQuery;
}

CQuery::~CQuery()
{
	if (pQuery)
		sqlite3_finalize(pQuery);
}