Guest User

Untitled

a guest
May 24th, 2018
435
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. <?php
  2.  
  3. class db
  4. {
  5. public $queries = 0;
  6. public $errors = array();
  7. function error()
  8. {
  9. $en = mysql_errno(); $e = mysql_error();
  10. if ( $en || $e ){
  11. $this->errors[] = $en . ' - ' . $e;
  12. }
  13. function __construct($svr, $usr, $pw, $db)
  14. {
  15. mysql_connect($svr, $usr, $pw);
  16. $this->error();
  17. mysql_select_db($db);
  18. $this->error();
  19. }
  20. function escape($str)
  21. {
  22. return mysql_real_escape_string($str);
  23. }
  24. function query($sql)
  25. {
  26. $this->queries++;
  27. $this->errors[] = 'Debug: ' . $sql;
  28. $result = mysql_query($sql);
  29. $this->error();
  30. return $result;
  31. }
  32. function rows($result)
  33. {
  34. $rows = mysql_num_rows($result);
  35. $this->error();
  36. return $rows;
  37. }
  38. function insert_id()
  39. {
  40. $id = mysql_insert_id();
  41. $this->error();
  42. return $id;
  43. }
  44. function affected_rows()
  45. {
  46. $rows = mysql_affected_rows();
  47. $this->error();
  48. return $rows;
  49. }
  50. function fetch($result)
  51. {
  52. $row = mysql_fetch_assoc($result);
  53. $this->error();
  54. return $row;
  55. }
  56. }
  57.  
  58. ?>
Add Comment
Please, Sign In to add comment