Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. <?php
  2. class mysqlidata
  3. {
  4. private $link;
  5. private $result;
  6.  
  7. function __construct()
  8. {
  9. $host = "localhost";
  10. $user = "root";
  11. $pass = "";
  12. $dbase = "kenny";
  13. $this->result = false;
  14. $this->link = new mysqli($host, $user, $pass, $dbase)
  15. or die ("can not connect to mysqli server");
  16.  
  17. }
  18.  
  19. public function getAll($tablename,$colom)
  20. {
  21. $array = array();
  22.  
  23. //als er nog een oude resultset in het geheugen is dan ruimen we die netjes op
  24. if($this->result)
  25. $this->result->close();
  26.  
  27. $this->result = $this->link->query('SELECT * FROM '.$tablename);
  28.  
  29. //indien de query niet gelukt is geven we een foutmelding
  30. if(!$this->result)
  31. {
  32. echo $this->link->error;
  33. return $array;
  34. }
  35.  
  36. //prop alle rijen in een array
  37. while($row = $this->result->fetch_assoc())
  38. {
  39. $db[]= $row[$colom];
  40. }
  41.  
  42. return $db;
  43. }
  44.  
  45. public function numRows()
  46. {
  47. // even checken of we wel een resultset hebben
  48. if(!$this->result)
  49. return false;
  50.  
  51. return $this->result->num_rows;
  52. }
  53. }
  54.  
  55. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement