Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Database
- {
- private $hostname = 'DESKTOP-S3L4V04\SQLEXPRESS';
- private $port = '1433';
- private $dbname = 'ACCOUNT_DBF';
- private $username = 'DESKTOP-S3L4V04\Dylan';
- private $password = '';
- protected $db = NULL;
- public function __construct()
- {
- $this->connect();
- }
- public function connect()
- {
- try
- {
- echo 'bug';
- //$db = new PDO("sqlsrv:Server=" + $this->hostname + "," + $this->port + ";Database=" + $this->dbname, $this->username, $this->password);
- $db = new PDO("sqlsrv:Server=$this->hostname;Database=$this->dbname", $this->username, $this->password);
- echo 'Connexion acceptée';
- }
- catch(Exception $e)
- {
- echo $e->getMessage();
- }
- }
- public function close()
- {
- $db = NULL;
- }
- public function isAlive()
- {
- if($db)
- return TRUE;
- else
- return FALSE;
- }
- };
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement