Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Models;
  4. class Db
  5. {
  6. protected $dbh;
  7.  
  8. public function __construct()
  9. {
  10. $config = (include __DIR__ . '/../../config.php')['db'];
  11. $this->dbh = new \PDO('mysql:host=' . $config['host'] . ';dbname=' . $config['dbname'], $config['user'], $config['password']);
  12. }
  13.  
  14. public function query($class)
  15. {
  16. return $this->dbh->query()->fetchAll(\PDO::FETCH_CLASS, $class);
  17.  
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement