Guest User

Untitled

a guest
Jul 17th, 2018
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. <?php
  2. class DB{
  3. var $db_encoding="UTF-8";
  4. var $script_encoding="UTF-8";
  5. var $db=null;
  6.  
  7. #---------------------------
  8. # constructer
  9. #---------------------------
  10. function DB($db=DBNAME,$user=USER,$pass=PASS,$host=HOST){
  11. # CONNECT MySQL
  12. if (!($mysql=mysql_connect($host,$user,$pass,true))) {
  13. die("ERROR: HOST CONNECT FAILED");
  14. }
  15.  
  16. $this->db = $mysql ;
  17.  
  18. # CONNECT DB
  19. if (!(mysql_select_db($db,$this->db))) {
  20. die("ERROR: DB CONNECT FAILED");
  21. }
  22. }
  23.  
  24. #---------------------------
  25. # class method
  26. #---------------------------
  27. function exe($stmt){
  28. # Execute SQL
  29. if (!($data = mysql_query($stmt,$this->db))) {
  30. echo mysql_error($this->db)."\n";
  31. var_dump($stmt);
  32. return false;
  33. }
  34. $result = Array();
  35. while($tmp = @mysql_fetch_assoc($data)){
  36. array_push($result,$tmp);
  37. }
  38. if( !empty ( $result ) ){
  39. return $result;
  40. }else{
  41. return TRUE;
  42. }
  43. }
  44. }
Add Comment
Please, Sign In to add comment