Merge remote-tracking branch 'origin/dev-battle-fighterclass' into dev-battle-fighterclass
This commit is contained in:
commit
65aa6fba8e
@ -10,13 +10,18 @@ require_once 'mysql_override.php';
|
||||
|
||||
spl_autoload_register(function (string $className) {
|
||||
$rootdir = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '_incl_data' . DIRECTORY_SEPARATOR;
|
||||
$addsrc = function ($class) {
|
||||
$c = explode('\\', $class);
|
||||
array_splice($c, 1, 0, 'src');
|
||||
return implode(DIRECTORY_SEPARATOR, $c);
|
||||
};
|
||||
# 1 with namespaces
|
||||
# 2 without
|
||||
$fileName = [
|
||||
$rootdir . 'class' . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $className . '.php'),
|
||||
$rootdir . 'class' . DIRECTORY_SEPARATOR . $className . '.php',
|
||||
$rootdir . 'function' . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $className . '.php'),
|
||||
$rootdir . 'vendor' . DIRECTORY_SEPARATOR . $className . '.php',
|
||||
$rootdir . 'vendor' . DIRECTORY_SEPARATOR . $addsrc($className) . '.php',
|
||||
];
|
||||
foreach ($fileName as $file) {
|
||||
if (file_exists($file)) {
|
||||
|
@ -53,11 +53,15 @@ class Db
|
||||
/**
|
||||
* @param string $query
|
||||
* @param array $args
|
||||
* @return false|array
|
||||
* @return array
|
||||
*/
|
||||
public static function getRows(string $query, array $args = []): false|array
|
||||
public static function getRows(string $query, array $args = []): array
|
||||
{
|
||||
return self::run($query, $args)->fetchAll();
|
||||
$stmt = self::run($query, $args)->fetchAll();
|
||||
if (!$stmt) {
|
||||
return [];
|
||||
}
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -108,19 +112,23 @@ class Db
|
||||
{
|
||||
$result = self::getRow($query, $args);
|
||||
if (!empty($result)) {
|
||||
$result = array_shift($result);
|
||||
return array_shift($result);
|
||||
}
|
||||
return $result;
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $query
|
||||
* @param array $args
|
||||
* @return mixed
|
||||
* @return array
|
||||
*/
|
||||
public static function getRow(string $query, array $args = []): mixed
|
||||
public static function getRow(string $query, array $args = []): array
|
||||
{
|
||||
return self::run($query, $args)->fetch();
|
||||
$stmt = self::run($query, $args)->fetch();
|
||||
if (!$stmt) {
|
||||
return [];
|
||||
}
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -130,7 +138,11 @@ class Db
|
||||
*/
|
||||
public static function getColumn(string $query, array $args = []): array
|
||||
{
|
||||
return self::run($query, $args)->fetchAll(PDO::FETCH_COLUMN);
|
||||
$stmt = self::run($query, $args)->fetchAll(PDO::FETCH_COLUMN);
|
||||
if (!$stmt) {
|
||||
return [];
|
||||
}
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -20,6 +20,16 @@ class Reputation
|
||||
}
|
||||
}
|
||||
|
||||
private function getr(): array
|
||||
{
|
||||
return Db::getRow(
|
||||
'select *,
|
||||
(repcapitalcity+repdemonscity+repangelscity+repsuncity+repdreamscity+repabandonedplain+repsandcity+repemeraldscity+repdevilscity) as allrep,
|
||||
(nu_capitalcity+nu_demonscity+nu_angelscity+nu_suncity+nu_dreamscity+nu_abandonedplain+nu_sandcity+nu_emeraldscity+nu_devilscity) as allnurep
|
||||
from rep where id = ?', [$this->uid]
|
||||
);
|
||||
}
|
||||
|
||||
public function get(): array
|
||||
{
|
||||
return $this->r;
|
||||
@ -34,14 +44,4 @@ class Reputation
|
||||
Db::sql("update rep set $dungeonName = ? where id = ?", [$value, $this->uid]);
|
||||
return $this->r[$dungeonName];
|
||||
}
|
||||
|
||||
private function getr()
|
||||
{
|
||||
return Db::getRow(
|
||||
'select *,
|
||||
(repcapitalcity+repdemonscity+repangelscity+repsuncity+repdreamscity+repabandonedplain+repsandcity+repemeraldscity+repdevilscity) as allrep,
|
||||
(nu_capitalcity+nu_demonscity+nu_angelscity+nu_suncity+nu_dreamscity+nu_abandonedplain+nu_sandcity+nu_emeraldscity+nu_devilscity) as allnurep
|
||||
from rep where id = ?', [$this->uid]
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user