Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2017
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. <?php
  2. class Database {
  3. private $host='localhost';
  4. private $user="admin";
  5. private $pass="12345";
  6. private $db="db2";
  7.  
  8. function connectToDb() {
  9. if($conn = mysqli_connect($this->host, $this->user,$this->pass)) {
  10.  
  11. if($db=mysqli_select_db($conn,$this->db)) {
  12.  
  13. }
  14. }
  15. }
  16. function closeConnection() {
  17. mysqli_close();
  18. }
  19. }
  20. ?>
  21.  
  22. <?php
  23. class Select extends Database{
  24.  
  25. private $tabname;
  26. function __construct($tablename) {
  27. $this->connectToDb();
  28. $this->tabname = $tablename;
  29. }
  30.  
  31. function getRecordById($id) {
  32. $query = "SELECT * FROM $this->tabname WHERE id = '$id'";
  33. if($sql=mysqli_query($query)){
  34. $data=mysqli_fetch_array();
  35. }
  36. return $data;
  37. }
  38.  
  39. function getAllData() {
  40.  
  41. }
  42. }
  43. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement