"127.0.0.1", "db_user" => "regi2p", "db_pass" => "password", "db_name" => "regi2p", ]; public function __construct(array $options = []) { $this->options = array_merge($this->options, (array) $options); try { $this->pdo = new PDO("mysql:host=".$this->options["db_host"].";dbname=".$this->options["db_name"], $this->options["db_user"], $this->options["db_pass"]); $this->pdo->setAttribute(PDO::ATTR_TIMEOUT, 20); $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $this->pdo->exec("set names utf8mb4"); } catch(PDOException $e) { exit("Database connection error: " . $e . PHP_EOL); } } public function __destruct() { $pdo = null; } }