Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. <?php
  2. class Database {
  3. private $host = "localhost";
  4. private $user = "root";
  5. private $password = "root";
  6. private $database = "crud";
  7.  
  8. function runQuery($sql) {
  9. $conn = new mysqli($this->host,$this->user,$this->password,$this->database);
  10. if ($conn->connect_error) {
  11. die("Connection failed: " . $conn->connect_error);
  12. }
  13. $result = $conn->query($sql);
  14. if ($result->num_rows > 0) {
  15. while($row = $result->fetch_assoc()) {
  16. $resultset[] = $row;
  17. }
  18. }
  19. $conn->close();
  20. if(!empty($resultset))
  21. return $resultset;
  22. }
  23. }
  24. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement