Guest User

Untitled

a guest
Jul 23rd, 2018
138
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. error_reporting(E_ALL);
  3. class mysqlclass
  4. {
  5. private $_host;
  6. private $_user;
  7. private $_pass;
  8. private $_name;
  9. private $_query;
  10. private $_con;
  11. private $_conta;
  12.  
  13. public function __construct($host_db, $user_db, $pass_db, $name_db)
  14. {
  15. $this->_host = $host_db;
  16. $this->_user = $user_db;
  17. $this->_pass = $pass_db;
  18. $this->_name = $name_db;
  19. }
  20.  
  21. public function connect()
  22. {
  23. $this->_con = mysql_connect($this->_host, $this->_user, $this->_pass) or die(mysql_error());
  24. mysql_select_db($this->_name, $this->_con) or die(mysql_error());
  25. }
  26.  
  27. public function query($query)
  28. {
  29. $this->_query = $query;
  30. return mysql_query($this->_query) or die(mysql_error());
  31. }
  32.  
  33. public function conta($query1)
  34. {
  35. $this->_conta = $query1;
  36. return mysql_num_rows($this->_conta) or die(mysql_error());
  37. }
  38.  
  39. public function __destruct()
  40. {
  41. mysql_close($this->_con);
  42. }
  43. }
  44.  
  45. ?>
Add Comment
Please, Sign In to add comment