Advertisement
interteck

User.php

Feb 8th, 2015
769
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. <?php
  2.  
  3. class User {
  4.  
  5. private $dbh;
  6. private $user = 'root';
  7. private $pass = '';
  8. #private $dsn = 'mysql:dbname=test;host=localhost';
  9.  
  10. public function __construct($host,$user,$pass,$db) {
  11. #$this->dbh = new PDO("mysql:host=".$host.";dbname=".$db,$user,$pass);
  12. $this->dbh = new PDO("mysql:localhost=".$host.";test=".$db,$user,$pass);
  13. #$dbh = new PDO($dsn,$user,$pass);
  14. }
  15.  
  16.  
  17. public function getUsers(){
  18. $sth = $this->dbh->prepare("SELECT * FROM pengguna");
  19. $sth->execute();
  20. return json_encode($sth->fetchAll());
  21. }
  22. }
  23. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement