Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class User extends Database
- {
- public function data($userid)
- {
- $getRow = $this->getConnect()->getRow("SELECT * FROM users WHERE userid = ?", [$userid]);
- return $getRow;
- }
- }
- class Database
- {
- private $dbh = NULL;
- private $instance = NULL;
- public function __construct($username = 'root', $password = '', $host = '127.0.0.1', $dbname = 'testdb', $options = [])
- {
- try {
- $this->dbh = new PDO("mysql:dbname={$dbname};host={$host};charset=utf8", $username, $password);
- $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $this->dbh->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
- } catch (PDOException $ex) {
- throw new Exception($ex->getMessage());
- }
- }
- public function getConnect()
- {
- if($this->instance == NULL)
- {
- $this->instance = new self();
- }
- return $this->instance;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement