Advertisement
Guest User

Untitled

a guest
Jun 11th, 2012
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.11 KB | None | 0 0
  1. <?php
  2.  
  3. abstract class dbConfig
  4. {
  5.     private $host;
  6.     private $name;
  7.     private $pass;
  8.     private $database;
  9.     private $table;
  10.     private $connector;
  11.  
  12.     function __construct($hostname = NULL, $username = NULL, $pass = NULL, $database = NULL, $prefix = NULL, $connector = NULL)
  13.     {
  14.         $this->hostname = !empty($hostname) ? $hostname : "";
  15.         $this->username = !empty($username) ? $username : "";
  16.         $this->pass = !empty($pass) ? $pass : "";
  17.         $this->database = !empty($database) ? $database : "";
  18.         $this->table = !empty($table) ? $table : "";
  19.         $this->connector = !empty($connector) ? $connector : "";  //mysql of mysqli waarde opgeven (database)
  20.     }
  21.  
  22.     public function getHost()
  23.     {
  24.         return $this->host;
  25.     }
  26.  
  27.     public function getName()
  28.     {
  29.         return $this->name;
  30.     }
  31.  
  32.     public function getPass()
  33.     {
  34.         return $this->pass;
  35.     }
  36.  
  37.     public function getDatabase()
  38.     {
  39.         return $this->database;
  40.     }
  41.  
  42.     public function getTable()
  43.     {
  44.         return $this->table;
  45.     }
  46.  
  47.     public function getConnector()
  48.     {
  49.         return $this->connector;
  50.     }
  51.  
  52.     function __destruct()
  53.     {
  54.         #destruction!
  55.     }
  56. }
  57.  
  58. class dbConnect
  59. {
  60.     private $link;
  61.  
  62.     public function __construct($dbConfig)
  63.     {
  64.        
  65.     }
  66.  
  67.     public function openConnection()
  68.     {
  69.         return $this->openConnection;
  70.     }
  71.  
  72.     public function closeConnection()
  73.     {
  74.         return $this->closeConnection;
  75.     }
  76.  
  77.     public function getLink()
  78.     {
  79.         return $this->link;
  80.     }
  81.  
  82. }
  83.  
  84. class dbConnectMySQL extends dbConnect
  85. {
  86.     public function openConnection()
  87.     {
  88.         try
  89.                 {
  90.                                 $this->openConnect = mysql_connect($this->hostname, $this->username, $this->pass);
  91.                                 $this->databaseConnect = mysql_select_db($this->database);    
  92.                 }
  93.                 catch (Exception $e)
  94.                 {
  95.                         return $e;
  96.                 }
  97.     }
  98.  
  99.     public function closeConnection()
  100.         {
  101.                 try {
  102.                                 mysql_close($this->openConnect);
  103.                 }
  104.                 catch (Exception $e)
  105.                 {
  106.                         return $e;
  107.                 }
  108.         }
  109. }
  110.  
  111. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement