Advertisement
Guest User

Untitled

a guest
Nov 11th, 2016
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. namespace App\Models;
  2.  
  3. abstract class Models
  4. {
  5.  
  6. protected $connection;
  7.  
  8. protected $host = 'localhost';
  9.  
  10. protected $db = 'db';
  11.  
  12. protected $user = 'user';
  13.  
  14. protected $password = 'password';
  15.  
  16. protected $charset = 'utf-8';
  17.  
  18. protected $type = 'mysql';
  19.  
  20. function __construct()
  21. {
  22. $this->connection = new \PDO(
  23. $this->type.":host=".$this->host.";dbname=".$this->db.";charset=".$this->charset,
  24. $this->user,
  25. $this->password,
  26. [
  27. \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
  28. \PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC
  29. ]
  30. );
  31. }
  32.  
  33. public function getConnection(){
  34. return $this->connection;
  35. }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement