Posted By

Monferno on 07/08/11


Tagged

mysql php


Versions (?)

MySQL Class


 / Published in: PHP
 

  1. <?php
  2. /**
  3.  * Created by JetBrains PhpStorm.
  4.  * User: Joshua
  5.  * Date: 07/07/11
  6.  * Time: 17:14
  7.  * To change this template use File | Settings | File Templates.
  8.  */
  9.  
  10. class SimpleMySQL {
  11. var $Conn = null;
  12. var $ConnectionID = null;
  13. var $Host = null;
  14. var $User = null;
  15. private $Password = null;
  16. var $Database = null;
  17. var $QueryCount = 0;
  18. var $Error = null;
  19. var $LastQuery = null;
  20.  
  21. function Connect($host, $user, $pass, $db) {
  22. $this->Host = $host;
  23. $this->User = $user;
  24. $this->Password = $pass;
  25. $this->Database = $db;
  26.  
  27. $this->ConnectionID = md5($host . $user . $pass . $db);
  28.  
  29. $this->Conn = mysql_connect($host, $user, $pass);
  30. mysql_select_db($db, $this->Conn);
  31. }
  32.  
  33. function Query($sql) {
  34. $this->QueryCount++;
  35.  
  36. $q = mysql_query($sql);
  37. $this->Error = mysql_error();
  38. $this->LastQuery = $sql;
  39.  
  40. return $q;
  41. }
  42.  
  43. function RowCount($rset) {
  44. $rows = mysql_num_rows($rset);
  45.  
  46. return $rows;
  47. }
  48.  
  49. function GetResults($rset) {
  50. return mysql_fetch_object($rset);
  51. }
  52. }

Report this snippet  

You need to login to post a comment.