SHARE
TWEET

Untitled

zlumber Jun 11th, 2012 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. include_once('IConnectInfo.php');
  4.  
  5. class UniversalConnect implements IConnectInfo
  6. {
  7.         private $server=IConnectInfo::HOST;
  8.         private $currentDB= IConnectInfo::DBNAME;
  9.         private $user= IConnectInfo::UNAME;
  10.         private $pass= IConnectInfo::PW;
  11.     public function __construct ($server,$currentDB, $user, $pass ){
  12.  
  13. $this->server=$server;
  14. $this->currentDB=$currentDB;
  15. $this->user=$user;
  16. $this->pass=$pass;
  17. }
  18. public function doConnect(){
  19. mysql_connect($this->server, $this->currentDB, $this->user, $this->pass);
  20. OR die ('Database is error');
  21. }
  22. public function ChangeDoConnect($PortDB){
  23. mysql_select_db ($PortDB)
  24. OR die ('Database is error');
  25. }
  26. }
  27. $PortDB = new UniversalConnect ('localhost', 'root', '');
  28. $PortDB -> doConnect();
  29. $PortDB-> ChangeDoConnect('test1');
  30. echo 'Database DB1 is Connected';
  31.  
  32. $PortDB = new UniversalConnect('localhost', 'root', '');
  33. $PortDB -> doConnect();
  34. $PortDB-> ChangeDoConnect('test2');
  35. echo 'Database DB2 is Connected';
  36.  
  37. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top