Core/DBLayer: make use of return result of Connection::Open method and allow core to output all the errors in prepared statements instead of aborting on first error.

This commit is contained in:
Azazel
2011-04-07 15:30:38 +06:00
parent 770c8a950e
commit 4db04b63dd
9 changed files with 39 additions and 57 deletions
@@ -17,16 +17,11 @@
#include "LoginDatabase.h"
bool LoginDatabaseConnection::Open()
void LoginDatabaseConnection::DoPrepareStatements()
{
if (!MySQLConnection::Open())
return false;
if (!m_reconnecting)
m_stmts.resize(MAX_LOGINDATABASE_STATEMENTS);
/* ################ LOAD PREPARED STATEMENTS HERE ################ */
PREPARE_STATEMENT(LOGIN_GET_REALMLIST, "SELECT id, name, address, port, icon, color, timezone, allowedSecurityLevel, population, gamebuild FROM realmlist WHERE color <> 3 ORDER BY name", CONNECTION_SYNCH)
PREPARE_STATEMENT(LOGIN_SET_EXPIREDIPBANS, "DELETE FROM ip_banned WHERE unbandate<>bandate AND unbandate<=UNIX_TIMESTAMP()", CONNECTION_ASYNC)
PREPARE_STATEMENT(LOGIN_SET_EXPIREDACCBANS, "UPDATE account_banned SET active = 0 WHERE active = 1 AND unbandate<>bandate AND unbandate<=UNIX_TIMESTAMP()", CONNECTION_ASYNC)
@@ -47,13 +42,4 @@ bool LoginDatabaseConnection::Open()
PREPARE_STATEMENT(LOGIN_SET_IP_NOT_BANNED, "DELETE FROM ip_banned WHERE ip = ?", CONNECTION_ASYNC)
PREPARE_STATEMENT(LOGIN_SET_ACCOUNT_BANNED, "INSERT INTO account_banned VALUES (?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+?, ?, ?, 1)", CONNECTION_ASYNC)
PREPARE_STATEMENT(LOGIN_SET_ACCOUNT_NOT_BANNED, "UPDATE account_banned SET active = 0 WHERE id = ? AND active != 0", CONNECTION_ASYNC)
/* ############## END OF LOADING PREPARED STATEMENTS ############## */
for (PreparedStatementMap::const_iterator itr = m_queries.begin(); itr != m_queries.end(); ++itr)
{
PrepareStatement(itr->first, itr->second.first, itr->second.second);
}
return true;
}