Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class DataConnection
- {
- private $host = 'localhost';
- private $user = 'genny';
- private $pass = 'genny';
- private $dbname = 'progetto';
- private $dbh;
- private $error;
- public function __construct()
- {
- // Set DSN
- $dsn = 'mysql:host=' . $this->host . ';dbname=' . $this->dbname;
- // Set options
- $options = array(
- PDO::ATTR_PERSISTENT => true,
- PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
- );
- // Create a new PDO instanace
- try {
- $this->dbh = new PDO($dsn, $this->user, $this->pass, $options);
- } // Catch any errors
- catch (PDOException $e) {
- $this->error = $e->getMessage();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement