Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class User {
- private $dbh;
- private $user = 'root';
- private $pass = '';
- #private $dsn = 'mysql:dbname=test;host=localhost';
- public function __construct($host,$user,$pass,$db) {
- #$this->dbh = new PDO("mysql:host=".$host.";dbname=".$db,$user,$pass);
- $this->dbh = new PDO("mysql:localhost=".$host.";test=".$db,$user,$pass);
- #$dbh = new PDO($dsn,$user,$pass);
- }
- public function getUsers(){
- $sth = $this->dbh->prepare("SELECT * FROM pengguna");
- $sth->execute();
- return json_encode($sth->fetchAll());
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement