mirror of
https://github.com/smogon/pokemon-showdown-client.git
synced 2026-03-21 09:35:44 -05:00
Set timeout in PDO constructor instead of a seperate query
Some checks failed
Node.js CI / build (22.x) (push) Has been cancelled
Some checks failed
Node.js CI / build (22.x) (push) Has been cancelled
This commit is contained in:
parent
4e19006b9e
commit
13f7725cf1
|
|
@ -25,13 +25,12 @@ class PSDatabase {
|
|||
if (!$this->db) {
|
||||
try {
|
||||
$this->db = new PDO(
|
||||
"mysql:dbname={$this->database};host={$this->server};charset={$this->charset}",
|
||||
"mysql:dbname={$this->database};host={$this->server};charset={$this->charset};wait_timeout=7200",
|
||||
$this->username,
|
||||
$this->password,
|
||||
[PDO::ATTR_PERSISTENT => true]
|
||||
);
|
||||
$this->db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
|
||||
$this->db->exec("SET SESSION wait_timeout = 7200");
|
||||
} catch (PDOException $e) {
|
||||
if (strpos($e->getMessage(), '1040') !== false || strpos($e->getMessage(), 'Too many connections') !== false) {
|
||||
http_response_code(503);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user