Spaces:
Sleeping
Sleeping
File size: 813 Bytes
27f4352 049c2f5 c7a81d9 68c7bdd ac85ccd 68c7bdd 049c2f5 27f4352 049c2f5 27f4352 7a8e049 27f4352 049c2f5 27f4352 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | <?php
class Database {
// 1. Hardcode your static Aiven strings
private $host = "tokistiersql-tiersapp.i.aivencloud.com";
private $db_name = "defaultdb";
private $username = "avnadmin";
private $port = "11606";
private $password;
public $conn;
public function getConnection() {
$this->conn = null;
$this->password = getenv("AIVEN_DB_PASS");
try {
$this->conn = new PDO("mysql:host=" . $this->host . ";port=" . $this->port . ";dbname=" . $this->db_name, $this->username, $this->password);
$this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $exception) {
echo "Connection error: " . $exception->getMessage();
}
return $this->conn;
}
}
?> |