Guest User

Untitled

a guest
Dec 13th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. <?php
  2.  
  3. class myPDO {
  4.  
  5. var $driver = 'mysql';
  6. var $host = 'localhost';
  7. var $dbname = 'database';
  8. var $username = 'username';
  9. var $password = 'password';
  10. var $charset = 'utf8';
  11. var $conn = '';
  12. var $stmt = '';
  13. var $result = '';
  14.  
  15. function conn($driver = '', $host = '', $dbname = '', $username = '', $password = '', $charset = 'utf8') {
  16. $this->driver = $driver;
  17. $this->host = $host;
  18. $this->dbname = $dbname;
  19. $this->username = $username;
  20. $this->password = $password;
  21. $this->charset = $charset;
  22.  
  23. $this->conn = new pdo("$this->driver:host=$this->host;dbname=$this->dbname;charset=$this->charset;", $this->username, $this->password);
  24. }
  25.  
  26. function sql($sql='') {
  27. $this->stmt = $this->conn->prepare($sql);
  28. }
  29.  
  30. function result($input=[], $fetch_style = PDO::FETCH_ASSOC) {
  31. $this->stmt->execute($input);
  32. return $this->stmt->fetchAll($fetch_style);
  33. }
  34.  
  35. function row($input=[], $fetch_style = PDO::FETCH_ASSOC) {
  36. $this->stmt->execute($input);
  37. return $this->stmt->fetch($fetch_style);
  38. }
  39.  
  40. }
Add Comment
Please, Sign In to add comment