Advertisement
Guest User

Untitled

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