Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class GramofoonService
- {
- private static $instance = null;
- function getDBConnectie(){
- $dns = 'mysql:host=localhost;port=3306;dbname=maii_gramobiel';
- $user = 'usr_devinemobiel';
- $pass = 'devine';
- if(is_null(self::$instance)){
- self::$instance = new PDO($dns,$user,$pass);
- }
- return self::$instance;
- }
- function getWagens(){
- $sql = "SELECT * FROM wagens";
- $dbc = $this->getDBConnectie();
- $stmt = $dbc->prepare($sql);
- if ($stmt->execute() !== false) {
- $wagens = array();
- while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
- $wagens[] = $row;
- }
- return $wagens;
- } else {
- //error
- }
- }
- }
Add Comment
Please, Sign In to add comment