Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. <?php
  2. class DBController {
  3. private $host = "localhost";
  4. private $user = "root";
  5. private $password = "";
  6. private $database = "phppot_examples";
  7. private $conn;
  8.  
  9. function __construct() {
  10. $this->conn = $this->connectDB();
  11. }
  12.  
  13. function connectDB() {
  14. $conn = mysqli_connect($this->host,$this->user,$this->password,$this->database);
  15. return $conn;
  16. }
  17.  
  18. function runQuery($query) {
  19. $result = mysqli_query($this->conn,$query);
  20. while($row=mysqli_fetch_assoc($result)) {
  21. $resultset[] = $row;
  22. }
  23. if(!empty($resultset))
  24. return $resultset;
  25. }
  26.  
  27. function numRows($query) {
  28. $result = mysqli_query($this->conn,$query);
  29. $rowcount = mysqli_num_rows($result);
  30. return $rowcount;
  31. }
  32. }
  33. ?>
  34.  
  35. function getUNS()
  36. {
  37.  
  38. $connectionInfo = array( "Database"=>"Data", "UID"=>"IDBAS", "PWD"=>"PASS");
  39. $conn = sqlsrv_connect( "localhost", $connectionInfo);
  40.  
  41. return $conn;
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement