Changeset - 1309637a5843
[Not reviewed]
0 1 0
Jan Kaluza - 10 years ago 2015-11-25 16:23:13
jkaluza@redhat.com
SQLite3Backend::setUser - use null for the 'id' when user.id is 0
1 file changed with 5 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/SQLite3Backend.cpp
Show inline comments
 
@@ -214,25 +214,30 @@ bool SQLite3Backend::exec(const std::string &query) {
 
		// to detect if DB is created properly.
 
		if (errMsg && std::string(errMsg).find("table buddies already exists") == std::string::npos) {
 
			LOG4CXX_ERROR(logger, errMsg << " during statement " << query);
 
		}
 
		sqlite3_free(errMsg);
 
		return false;
 
	}
 
	return true;
 
}
 

	
 
void SQLite3Backend::setUser(const UserInfo &user) {
 
	sqlite3_reset(m_setUser);
 
	if (user.id == 0) {
 
		sqlite3_bind_null(m_setUser, 1);
 
	}
 
	else {
 
		sqlite3_bind_int(m_setUser, 1, user.id);
 
	}
 
	sqlite3_bind_text(m_setUser, 2, user.jid.c_str(), -1, SQLITE_STATIC);
 
	sqlite3_bind_text(m_setUser, 3, user.uin.c_str(), -1, SQLITE_STATIC);
 
	sqlite3_bind_text(m_setUser, 4, user.password.c_str(), -1, SQLITE_STATIC);
 
	sqlite3_bind_text(m_setUser, 5, user.language.c_str(), -1, SQLITE_STATIC);
 
	sqlite3_bind_text(m_setUser, 6, user.encoding.c_str(), -1, SQLITE_STATIC);
 
	sqlite3_bind_int (m_setUser, 7, user.vip);
 

	
 
	if(sqlite3_step(m_setUser) != SQLITE_DONE) {
 
		LOG4CXX_ERROR(logger, "setUser query"<< (sqlite3_errmsg(m_db) == NULL ? "" : sqlite3_errmsg(m_db)));
 
	}
 
}
 

	
0 comments (0 inline, 0 general)