SHARE
TWEET

Untitled

a guest Aug 18th, 2018 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top