Advertisement
Guest User

Untitled

a guest
May 26th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. function __construct($strHost='', $strDB='', $strUser='', $strPass='')
  2. {
  3. try{
  4.  
  5. if($strHost != ''){$this->strHost = $strHost;}
  6. if($strDB != ''){$this->strDB = $strDB;}
  7. if($strUser != ''){$this->strUser = $strUser;}
  8. if($strPass != ''){$this->strPass = $strPass;}
  9.  
  10. $this->objDB = new PDO("mysql:host=".$this->strHost.";port=3306;dbname=".$this->strDB,$this->strUser, $this->strPass, array( PDO::ATTR_PERSISTENT => true));
  11. if($this->objDB)
  12. {
  13. return $this->objDB;
  14. }
  15. else
  16. {
  17. echo "Database Connection Failed.";die;
  18. }
  19. }
  20. catch(Exception $objException)
  21. {
  22. echo $objException->getMessage();exit;
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement