Guest User

Untitled

a guest
Aug 18th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. class GramofoonService
  2. {
  3. private static $instance = null;
  4.  
  5. function getDBConnectie(){
  6. $dns = 'mysql:host=localhost;port=3306;dbname=maii_gramobiel';
  7. $user = 'usr_devinemobiel';
  8. $pass = 'devine';
  9. if(is_null(self::$instance)){
  10. self::$instance = new PDO($dns,$user,$pass);
  11. }
  12. return self::$instance;
  13. }
  14. function getWagens(){
  15. $sql = "SELECT * FROM wagens";
  16. $dbc = $this->getDBConnectie();
  17. $stmt = $dbc->prepare($sql);
  18. if ($stmt->execute() !== false) {
  19. $wagens = array();
  20. while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
  21. $wagens[] = $row;
  22. }
  23. return $wagens;
  24.  
  25. } else {
  26. //error
  27. }
  28. }
  29. }
Add Comment
Please, Sign In to add comment