Advertisement
Guest User

Untitled

a guest
Sep 13th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. <!-- Mysql.class.php loaded -->
  2. <?php
  3.  
  4. class Mysql{
  5. var $connection;
  6. var $address;
  7. var $username;
  8. var $password;
  9. var $result;
  10. var $database;
  11. var $sql;
  12.  
  13. function __construct($address,$username,$password,$database){
  14. $this->address = $address;
  15. $this->username = $username;
  16. $this->password = $password;
  17. $this->database = $database;
  18. $this->connectToDatabase();
  19. $this->selectDatabase($this->database);
  20. }
  21.  
  22. function countRows(){
  23. return mysql_num_rows($this->result);;
  24. }
  25.  
  26. private function connectToDatabase(){
  27. print '<!-- Connected to Database -->';
  28. $this->connection = mysql_connect($this->address,$this->username,$this->password) or die(mysql_error());
  29. }
  30.  
  31. function selectDatabase($name){
  32. mysql_select_db($this->database, $this->connection);
  33. }
  34.  
  35. function query($sql){
  36. $this->sql = $sql;//NEED TO PUT IN SECURITY
  37. $this->result = mysql_query($this->sql, $this->connection) or die ("Error with query :<br />".mysql_error());
  38. if (!$this->result) {
  39. die('Query execution problem: ' . msql_error());
  40. }
  41. }
  42.  
  43. function getResult(){
  44. return $this->result;
  45. }
  46.  
  47. //Mysql Real Escape String function time and space saver.
  48. function c($string){
  49. return mysql_real_escape_string($string);
  50. }
  51.  
  52. function freeResult(){
  53. mysql_free_result($this->result);
  54. }
  55. function getSql(){
  56. return $this->sql;
  57. }
  58. }
  59. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement