Advertisement
Guest User

Untitled

a guest
Jun 12th, 2012
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.88 KB | None | 0 0
  1. <?php
  2.  
  3. abstract class dbConfig
  4. {
  5.     private $host = false;
  6.     private $name = false;
  7.     private $pass = false;
  8.  
  9.     function __construct($hostname, $username, $pass)
  10.     {
  11.         $this->host = $host;
  12.         $this->name = $name;
  13.         $this->pass = $pass;
  14.     }
  15.  
  16.     public function getHost($host)
  17.     {
  18.         return $this->host;
  19.     }
  20.  
  21.     public function getName($name)
  22.     {
  23.         return $this->name;
  24.     }
  25.  
  26.     public function getPass($pass)
  27.     {
  28.         return $this->pass;
  29.     }
  30.  
  31.     function __destruct()
  32.     {
  33.         #destruction!
  34.     }
  35. }
  36.  
  37. abstract class dbConnect
  38. {
  39.     private $link = false;
  40.  
  41.     public function __construct($dbConfig)
  42.     {
  43.        
  44.     }
  45.  
  46.     public function openConnection()
  47.     {
  48.         return $this->openConnection;
  49.     }
  50.  
  51.     public function closeConnection()
  52.     {
  53.         return $this->closeConnection;
  54.     }
  55.  
  56.     public function getLink()
  57.     {
  58.         return $this->link;
  59.     }
  60.  
  61. }
  62.  
  63. class dbConnectMySQL extends dbConnect
  64. {
  65.     public $host = false;
  66.     public $name;
  67.     public $pass;
  68.     public $database;
  69.     public $openConnection;
  70.     public $closeConnection;
  71.     public $startQuery;
  72.     public $getResults;
  73.  
  74.     public function __construct($host, $name, $pass, $database)
  75.     {
  76.         $this->host = $host;
  77.         $this->name = $name;
  78.         $this->pass = $pass;
  79.         $this->database = $database;
  80.     }
  81.  
  82.     public function openConnection()
  83.     {
  84.         try
  85.                 {
  86.                     $this->dbConnect = mysql_connect($this->host, $this->name, $this->pass);
  87.                     $this->dbConnect = mysql_select_db($this->database);
  88.                 }
  89.                 catch (Exception $e)
  90.                 {
  91.                         return $e;
  92.                 }
  93.     }
  94.  
  95.     public function startQuery($query)
  96.     {
  97.             try
  98.             {
  99.                     if(empty($this->openConnection))
  100.                     {
  101.                             $this->openConnection();
  102.  
  103.                                     $this->startQuery = mysql_query($query);
  104.  
  105.                             $this->closeConnection();
  106.                             return $this->startQuery;
  107.                     }      
  108.                     else
  109.                     {
  110.                            
  111.                                     $this->startQuery = mysql_query($query);
  112.  
  113.                             return $this->startQuery;
  114.                     }
  115.             }
  116.             catch (Exception $e)
  117.             {
  118.                     return $e;    
  119.             }
  120.     }
  121.  
  122.     public function getResults()
  123.     {
  124.             try
  125.             {
  126.                     return mysql_fetch_assoc($result);
  127.             }
  128.             catch (Exception $e)
  129.             {
  130.                     return $e;    
  131.             }
  132.     }
  133.  
  134.     public function closeConnection()
  135.     {
  136.             try
  137.             {
  138.                    mysql_close();
  139.             }
  140.             catch (Exception $e)
  141.             {
  142.                     return $e;
  143.             }
  144.     }
  145.  
  146.     public function __destruct()
  147.     {
  148.         #destruction
  149.    }
  150. }
  151.  
  152. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement