-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConnection.class.php
More file actions
39 lines (32 loc) · 1.04 KB
/
Copy pathConnection.class.php
File metadata and controls
39 lines (32 loc) · 1.04 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
/* Conexion a la base de DATOS */
class Connection
{
private static $link = null;
//localhost
private $mysql_host = "localhost";
private $mysql_database = "shmviewer";
private $mysql_user = "root";
private $mysql_password = "admin";
private static $instance = null;
private function __construct() {
self::$link = mysql_connect($this->mysql_host,$this->mysql_user,$this->mysql_password) or die(ErrorHandler::getInstance()->getError(ErrorHandler::$MYSQL_CONNECTION_ERROR));
if (self::$link){
mysql_select_db($this->mysql_database) or die(ErrorHandler::getInstance()->getError(ErrorHandler::$MYSQL_DATABASE_SELECTION_ERROR, array($this->mysql_database)));
}
}
public static function getInstance() {
if (empty(self::$instance) || empty(self::$link)) {
self::$instance = new Connection();
}
return self::$instance;
}
/**
* Retrieves the link needed to execute queries to the database
* @return <resourse> link
*/
public function getDBLink() {
return self::$link;
}
}
?>