Advertisement
Guest User

Untitled

a guest
Mar 12th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. <?php
  2.  
  3. class MySQL {
  4. private $_link = null;
  5. private $_host;
  6. private $_user;
  7. private $_password;
  8. private $_bdd;
  9.  
  10. /* Constructeur */
  11. function mysql($a_host, $a_user, $a_pass, $a_bdd) {
  12. $this->_host = $a_host;
  13. $this->_user = $a_user;
  14. $this->_password = $a_pass;
  15. $this->_bdd = $a_bdd;
  16. }
  17.  
  18. public function getLink() {
  19. return $this->_link;
  20. }
  21.  
  22. function sql_connect() {
  23. $this->_link = new PDO('mysql:host=' . $this->_host . ';dbname=' . $this->_bdd, $this->_user, $this->_password);
  24. $this->_link->query("SET NAMES 'utf8'");
  25. }
  26.  
  27. public function sql_close() {
  28. $this->_link = null;
  29. }
  30.  
  31. public function sql_query($a_query) {
  32. return $this->_link->query($a_query);
  33. }
  34.  
  35. public function sql_fetch_all($aStmt) {
  36. return $aStmt->fetchAll(PDO::FETCH_ASSOC);
  37. }
  38. public function sql_fetch($aStmt) {
  39. return $aStmt->fetch(PDO::FETCH_ASSOC);
  40. }
  41.  
  42. public function sql_quote($aQuote) {
  43. return $this->_link->quote($aQuote);
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement