Your Ad Here

Posted By

Sn0opy on 08/16/08


Tagged

mysql class


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

Sn0opy
wizard04
vali29


mySQL class


 / Published in: PHP
 

  1. <?
  2. class db {
  3. private $db;
  4. private $num;
  5. private $res;
  6. private $row;
  7.  
  8. public function __construct() {
  9. $this->connect();
  10. }
  11.  
  12. public function connect() {
  13. $this->db = mysql_connect(HOST, USER, PWD);
  14. }
  15.  
  16. public function disconnect() {
  17. mysql_close($this->db);
  18. }
  19.  
  20. public function query($query) {
  21. $this->res = mysql_query($query);
  22. return $this->res;
  23. }
  24.  
  25. public function numRows() {
  26. $this->num = mysql_num_rows($this->res);
  27. return $this->num;
  28. }
  29.  
  30. public function fetch() {
  31. $this->row = mysql_fetch_array($this->res);
  32. return $this->row;
  33. }
  34.  
  35. public function row($field) {
  36. return $this->row[$field];
  37. }
  38.  
  39. public function insertID() {
  40. $this->id = mysql_insert_id();
  41. return $this->id;
  42. }
  43. }
  44. ?>

Report this snippet  

You need to login to post a comment.