PHP:
public static function GetCharactersList($user, $pass)
{
if (Auth::IsValidLogin($user, $pass))
{
global $config;
$accountId = Auth::GetAccountId($user);
$finalArray = array();
// Define a mapping of class names to numeric values
$classMapping = array(
"Warrior" => 1,
"Mage" => 8,
// Add more mappings for other classes if needed
);
foreach ($config['mysqli']['realms'] as $realm)
{
$mysqli = mysqli_connect($realm['hostname'],
$realm['user'],
$realm['pass'],
$realm['database'],
$realm['port']);
mysqli_set_charset($mysqli, "utf8");
if ($query = $mysqli->prepare("SELECT
ac.characterName AS name,
dl.additional_data AS class
FROM
account_character AS ac
LEFT JOIN
data_logs AS dl ON ( dl.account_id = ac.accountId AND dl.source_oid = ac.characterId )
WHERE
ac.accountId = ? AND dl.data_name = 'CHARACTER_CREATED'"))
{
$query->bind_param('i', $accountId);
$query->execute();
$query->bind_result($charName, $charClass);
$realmArray = array();
while ($query->fetch())
{
$rowArray['realm'] = $realm['name'];
$rowArray['name'] = $charName;
$row_array['race'] = $charRace;
// Check if the class exists in the mapping array
if (array_key_exists($charClass, $classMapping)) {
$rowArray['class'] = $classMapping[$charClass];
} else {
// If class is not found in mapping, keep the original class name
$rowArray['class'] = $charClass;
}
array_push($realmArray, $rowArray);
}
if (!empty($realmArray))
array_push($finalArray, $realmArray);
$query->close();
}
}
if (!empty($finalArray))
{
echo json_encode($finalArray, JSON_PRETTY_PRINT);
}
}
}
Нужно добавить еще запрос проверка расы, но раса находиться в другой базе, ( в BLOB ) формате, если есть знающие людей помогите плз !