Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- interface Conn
- {
- public function GetConn();
- public function GetConfiguration();
- }
- class Config implements Conn
- {
- private $host = 'localhost';
- private $user = 'root';
- private $pass = 'hcoins';
- private $db = 'hcoins';
- private $dns = 'mysql';
- public $Authorize = 1;
- protected $conn;
- public function GetConn()
- {
- if($this->Authorize == 1)
- {
- try
- {
- $this->conn = new PDO(''.$this->dns.':host='.$this->host.';dbname='.$this->db,$this->user,$this->pass);
- $this->conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
- $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- return $this->conn;
- }
- catch(PDOException $exception)
- {
- $e = $exception->getMessage();
- echo $e;
- }
- }
- else
- {
- return print 'Nessun autorizzazione di connessione';
- }
- }
- public function GetConfiguration()
- {
- if(!file_exists('conn.php'))
- {
- return print 'File di configurazione globale non trovato';
- }
- if(!class_exists('Config'))
- {
- return print 'Classe di configurazione globale non trovata';
- }
- }
- public function GetAll()
- {
- $function1 = $this->GetConfiguration();
- $function2 = $this->GetConn();
- return $function1;
- return $function2;
- }
- }
- $conn = new Config;
- $conn->GetAll();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement