Guest User

Untitled

a guest
Sep 1st, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. <?php
  2. ##########################
  3. # ->Error_report and query class
  4. # ->By Paulo Serra
  5. # ->V. 1.0
  6. ##########################
  7.  
  8. require_once('exceptions.php');
  9.  
  10. class error_report extends debuger{
  11.  
  12. //insert here your db connection
  13. var $username = '';
  14. var $localhost = '';
  15. var $pass = '';
  16. var $db ='';
  17.  
  18. function __construct(){}
  19.  
  20. //Not been used in this version
  21. public function __set($data, $value) {
  22. $this->data[$data] = $value;
  23. }
  24. //Not been used in this version
  25. public function __get($data) {
  26. return $this->data[$data];
  27. }
  28.  
  29. //Make the connection
  30. private function db_connect(){
  31. if(!$coneccao = mysql_connect($this->localhost, $this->username, $this->pass)){
  32. $this -> error_handling(mysql_error(), 0);
  33. }
  34. if(!$bd = mysql_select_db($this->db)){
  35. $this -> error_handling(mysql_error(), 0);
  36. }
  37. return $coneccao;
  38. }
  39. //make the query
  40. public function query($query){
  41. $this->db_connect();
  42. if(!$sql = mysql_query($query)){
  43. $this -> error_handling(mysql_error(), $query);
  44. }
  45. return $sql;
  46. }
  47.  
  48. //Get the number of rows
  49. public function db_num_rows($sql){
  50. if(!$rows = mysql_num_rows($sql)){
  51. $this -> error_handling(mysql_error(), $sql);
  52. }else{
  53. return $rows;
  54. }
  55. }
  56. //Get the fields Name
  57. public function db_fields($sql){
  58. if(!$campos = mysql_fetch_field($sql)){
  59. $this -> error_handling(mysql_error(), $sql);
  60. }else{
  61. for($i=0; $i < mysql_num_fields($sql); $i++){
  62. $fields[$i] = mysql_field_name($sql, $i);
  63. }
  64. return $fields;
  65. }
  66. }
  67. //Get the data fromm DB
  68. public function db_data($sql){
  69. while($data = mysql_fetch_array($sql)){
  70. $resultado[] = $data;
  71. }
  72. return $resultado;
  73. }
  74. }
  75. ?>
Add Comment
Please, Sign In to add comment