From 731f648cd235da78828e2ae1e9cec74faf35b81f Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Sat, 12 Feb 2022 15:15:48 +0100 Subject: [PATCH] Setup/Misc * wrap db test in try/catch block * escape more mysql8 keywords --- includes/database.class.php | 14 ++++++++------ includes/profiler.class.php | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/includes/database.class.php b/includes/database.class.php index 2182f785..1d289d6a 100644 --- a/includes/database.class.php +++ b/includes/database.class.php @@ -56,14 +56,16 @@ class DB if (strstr($options['host'], ':')) [$options['host'], $port] = explode(':', $options['host']); - if ($link = @mysqli_connect($options['host'], $options['user'], $options['pass'], $options['db'], $port ?: $defPort)) - { + try { + $link = @mysqli_connect($options['host'], $options['user'], $options['pass'], $options['db'], $port ?: $defPort); mysqli_close($link); - return true; } - - $err = '['.mysqli_connect_errno().'] '.mysqli_connect_error(); - return false; + catch (Exception $e) + { + $err = '['.mysqli_connect_errno().'] '.mysqli_connect_error(); + return false; + } + return true; } public static function errorHandler($message, $data) diff --git a/includes/profiler.class.php b/includes/profiler.class.php index 315a0068..f642801b 100644 --- a/includes/profiler.class.php +++ b/includes/profiler.class.php @@ -429,7 +429,7 @@ class Profiler // talents for ($j = 0; $j < 3; $j++) { - $_ = DB::Aowow()->selectCol('SELECT spell AS ARRAY_KEY, MAX(IF(spell IN (?a), `rank`, 0)) FROM ?_talents WHERE class = ?d AND tab = ?d GROUP BY id ORDER BY row, col ASC', !empty($t[$i]) ? $t[$i] : [0], $char['class'], $j); + $_ = DB::Aowow()->selectCol('SELECT spell AS ARRAY_KEY, MAX(IF(spell IN (?a), `rank`, 0)) FROM ?_talents WHERE class = ?d AND tab = ?d GROUP BY id ORDER BY `row`, `col` ASC', !empty($t[$i]) ? $t[$i] : [0], $char['class'], $j); $data['talentbuild'.($i + 1)] .= implode('', $_); if ($data['activespec'] == $i) $data['talenttree'.($j + 1)] = array_sum($_);