Domain registry project http://reg.i2p/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

38 lines
924 B

<?php
namespace App;
use PDO;
class DB
{
public $pdo;
protected $options = [
"db_host" => "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;
}
}