Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool C_MetaverseManager::LoadSQLKevValues(const char* tableName, const char* id, KeyValues* kv, sqlite3* pDb)
- {
- if (!pDb)
- pDb = m_db;
- sqlite3_stmt *stmt = NULL;
- //DevMsg("loading from table name: %s _id %s\n", tableName, id);
- int rc = sqlite3_prepare(pDb, VarArgs("SELECT * from %s WHERE id = \"%s\"", tableName, id), -1, &stmt, NULL);
- if (rc != SQLITE_OK)
- DevMsg("prepare failed: %s\n", sqlite3_errmsg(pDb));
- bool bSuccess = false;
- int length;
- if (sqlite3_step(stmt) == SQLITE_ROW) // THIS IS WHERE THE LOOP CAN BE BROKEN UP AT!!
- {
- length = sqlite3_column_bytes(stmt, 1);
- if (length > 0)
- {
- CUtlBuffer buf(0, length, 0);
- buf.CopyBuffer(sqlite3_column_blob(stmt, 1), length);
- if (kv->ReadAsBinary(buf))
- bSuccess = true;
- buf.Purge();
- }
- else
- bSuccess = false;
- }
- sqlite3_finalize(stmt); // TODO: error checking? Maybe not needed, if this is like a close() operation.
- return bSuccess;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement