MySQL Database Class


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. class dbconnect {
  3.  
  4. function Connect($DBHOST, $DBUSER, $DBPASS, $THEDB){
  5.  
  6. $connection = mysql_connect("$DBHOST","$DBUSER","$DBPASS");
  7. mysql_select_db("$THEDB", $connection);
  8.  
  9. }//ends the connection function
  10.  
  11. function Close(){
  12.  
  13. mysql_close($connection);
  14.  
  15. }//ends the close function
  16.  
  17. function FetchRow($query){
  18. $rows = mysql_fetch_row($query);
  19. return $rows;
  20. }
  21.  
  22. function FetchArray($query){
  23. $array = mysql_fetch_array($query);
  24. return $array;
  25. }
  26.  
  27. function FetchObject($query){
  28. $array = mysql_fetch_object($query);
  29. return $array;
  30. }
  31.  
  32. function FetchNum($query){
  33. $num = mysql_num_rows($query);
  34. return $num;
  35. }
  36.  
  37. function Query($sql){
  38. $query = mysql_query($sql) or die(mysql_error());
  39. return $query;
  40. }//ends the query function
  41.  
  42. }//ends the class
  43. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.