Ejemplo n.º 1
0
/// establishes database connection
static bool account_db_sql_init(AccountDB* self)
{
	AccountDB_SQL* db = (AccountDB_SQL*)self;
	struct Sql *sql_handle = NULL;

	nullpo_ret(db);

	db->accounts = SQL->Malloc();
	sql_handle = db->accounts;

	if (SQL_ERROR == SQL->Connect(sql_handle, db->db_username, db->db_password,
	                              db->db_hostname, db->db_port, db->db_database)) {
		Sql_ShowDebug(sql_handle);
		SQL->Free(db->accounts);
		db->accounts = NULL;
		return false;
	}

	if (db->codepage[0] != '\0' && SQL_ERROR == SQL->SetEncoding(sql_handle, db->codepage))
		Sql_ShowDebug(sql_handle);

	Sql_HerculesUpdateCheck(db->accounts);
#ifdef CONSOLE_INPUT
	console->input->setSQL(db->accounts);
#endif
	return true;
}
Ejemplo n.º 2
0
Sql* account_db_sql_up(AccountDB* self) {
	AccountDB_SQL* db = (AccountDB_SQL*)self;
	Sql_HerculesUpdateCheck(db->accounts);
#ifdef CONSOLE_INPUT
	console->setSQL(db->accounts);
#endif
	return db->accounts;
}
Ejemplo n.º 3
0
/// establishes database connection
static bool account_db_sql_init(AccountDB* self)
{
	AccountDB_SQL* db = (AccountDB_SQL*)self;
	Sql* sql_handle;
	const char* username;
	const char* password;
	const char* hostname;
	uint16      port;
	const char* database;
	const char* codepage;

	nullpo_ret(db);
	db->accounts = SQL->Malloc();
	sql_handle = db->accounts;

	if( db->db_hostname[0] != '\0' )
	{// local settings
		username = db->db_username;
		password = db->db_password;
		hostname = db->db_hostname;
		port     = db->db_port;
		database = db->db_database;
		codepage = db->codepage;
	}
	else
	{// global settings
		username = db->global_db_username;
		password = db->global_db_password;
		hostname = db->global_db_hostname;
		port     = db->global_db_port;
		database = db->global_db_database;
		codepage = db->global_codepage;
	}

	if( SQL_ERROR == SQL->Connect(sql_handle, username, password, hostname, port, database) )
	{
		Sql_ShowDebug(sql_handle);
		SQL->Free(db->accounts);
		db->accounts = NULL;
		return false;
	}

	if( codepage[0] != '\0' && SQL_ERROR == SQL->SetEncoding(sql_handle, codepage) )
		Sql_ShowDebug(sql_handle);

	Sql_HerculesUpdateCheck(db->accounts);
#ifdef CONSOLE_INPUT
	console->input->setSQL(db->accounts);
#endif
	return true;
}
Ejemplo n.º 4
0
void account_db_sql_up(AccountDB* self) {
	AccountDB_SQL* db = (AccountDB_SQL*)self;
	Sql_HerculesUpdateCheck(db->accounts);
}