Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,28 @@ public function __construct() {
$this->view = new SettingsView($this);
}


private function getPvpStatsReplicaPdo(): \PDO {
return new \PDO(
'mysql:host=' . getenv('PVPSTATS_REPLICA_HOST') . ';port=' . getenv('PVPSTATS_REPLICA_PORT') . ';dbname=' . getenv('PVPSTATS_REPLICA_DB') . ';charset=utf8mb4',
getenv('PVPSTATS_REPLICA_USER'),
getenv('PVPSTATS_REPLICA_PASSWORD'),
[
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
]
);
}
Comment on lines +25 to +35

private function runPvpStatsReplicaQuery(string $query, array $params): array {
$stmt = $this->getPvpStatsReplicaPdo()->prepare($query);
foreach ($params as $key => $value) {
$stmt->bindValue(':' . $key, $value);
}
$stmt->execute();
return $stmt->fetchAll();
}
Comment on lines +25 to +44

public function loadHome() {
//must check that the user has the required capability
if (!current_user_can('game_master')) {
Expand Down Expand Up @@ -212,12 +234,10 @@ public function loadPvpRewards() {
$query .= " LIMIT $limitRewards";
}

$connection = ACoreServices::I()->getCharacterEm()->getConnection();
$queryResult = $connection->executeQuery(
$result = $this->runPvpStatsReplicaQuery(
$query,
array('winner' => $isWinner, 'month' => $month, 'year' => $year)
);
$result = $queryResult->fetchAllAssociative();
if ($result) {
$accountCounter = 0;
$pointsCounter = 0;
Expand Down Expand Up @@ -339,12 +359,10 @@ public function loadPvpRewards() {
ORDER BY total_battle DESC
LIMIT 10";

$connection = ACoreServices::I()->getCharacterEm()->getConnection();
$queryResult = $connection->executeQuery(
$result = $this->runPvpStatsReplicaQuery(
$query,
array('isWinner' => $isWinner, 'month' => $month, 'year' => $year)
);
$result = $queryResult->fetchAllAssociative();
}

$data = [
Expand Down
7 changes: 0 additions & 7 deletions src/acore-wp-plugin/src/Manager/ACoreServices.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ public function getAcoreAccountLastIp() {
$conn = $this->getAccountEm()->getConnection();
$stmt = $conn->prepare($query);
$stmt->bindValue(1, $user->get("user_login"));
$stmt->executeQuery();
$res = $stmt->executeQuery();
return $res->fetchOne();
}
Expand All @@ -343,7 +342,6 @@ public function getAcoreAccountTotaltime($beauty=false) {
$conn = $this->getAccountEm()->getConnection();
$stmt = $conn->prepare($query);
$stmt->bindValue(1, $user->get("user_login"));
$stmt->executeQuery();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was not necessary?

$res = $stmt->executeQuery();
$row = $res->fetchAssociative();
$total = isset($row["totaltime"]) ? (int) $row["totaltime"] : 0;
Expand All @@ -370,7 +368,6 @@ public function getAcoreAccountLastIpById($id) {
$conn = $this->getAccountEm()->getConnection();
$stmt = $conn->prepare($query);
$stmt->bindValue(1, $id);
$stmt->executeQuery();
$res = $stmt->executeQuery();
return $res->fetchOne();
}
Expand All @@ -383,7 +380,6 @@ public function getAcoreAccountIdByName($username) {
$conn = $this->getAccountEm()->getConnection();
$stmt = $conn->prepare($query);
$stmt->bindValue(1, $username);
$stmt->executeQuery();
$res = $stmt->executeQuery();
return $res->fetchOne();
}
Expand All @@ -396,7 +392,6 @@ public function getUserNameByUserId($usedId) {
$conn = $this->getAccountEm()->getConnection();
$stmt = $conn->prepare($query);
$stmt->bindValue(1, $usedId);
$stmt->executeQuery();
$res = $stmt->executeQuery();
return $res->fetchOne();
}
Expand All @@ -409,7 +404,6 @@ public function getRestorableItemsByCharacter($character) {
$conn = $this->getCharacterEm()->getConnection();
$stmt = $conn->prepare($query);
$stmt->bindValue(1, $character);
$stmt->executeQuery();
$res = $stmt->executeQuery();
return $res->fetchAllAssociative();
}
Expand All @@ -427,7 +421,6 @@ public function getGuildNameByLeader($guildLeaderGuid) {
$conn = $this->getCharacterEm()->getConnection();
$stmt = $conn->prepare($query);
$stmt->bindValue(1, $guildLeaderGuid);
$stmt->executeQuery();
$res = $stmt->executeQuery();
return $res->fetchOne();
}
Expand Down
Loading