Advertisement
zlumber

Untitled

Jun 11th, 2012
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  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. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement