host = $_ENV['DB_HOST'] ?? 'localhost'; $this->dbname = $_ENV['DB_NAME'] ?? 'chandj'; $this->user = $_ENV['DB_USER'] ?? 'chandj'; $this->pw = $_ENV['DB_PASS'] ?? ''; } function connect(){ $dsn = "mysql:host=".$this->host.";dbname=".$this->dbname.";charset=utf8"; $pdo = new PDO($dsn, $this->user, $this->pw); $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); return $pdo; } } ?>