Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Db {
- protected $link;
- private $host;
- private $user;
- private $pass;
- private $dbName;
- public function __construct($host, $user, $pass, $db) {
- $this->host = $host;
- $this->user = $user;
- $this->pass = $pass;
- $this->dbName = $db;
- $this->connect();
- }
- public function connect() {
- try
- {
- $this->link = new PDO("mysql:host=" . $this->host .
- ";dbname=" . $this->dbName . ";charset=utf8mb4", $this->user, $this->pass );
- $this->link->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $this->link->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
- } catch (PDOException $exc)
- {
- $this->setMessage($exc->getMessage());
- }
- }
- }
- $db = new Db(HOST, USER,PASS,DB)
- class Main extends DB {
- public function __construct() {
- }
- /** App methods bellow*/
- }
- $db2 = new Db(HOST2,USER2,PASS2,DB2);
- class User extends DB {
- public function __construct() {
- }
- /** App methods bellow*/
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement