/** * This method is used to connect to the current config database * * @return $this */ public function connect() { $dsn = 'mysql:host=' . Config::read('db.host') . ';dbname=' . Config::read('db.name') . ';connect_timeout=15'; //We use the @ symbol to suppress "mysql server has gone away" errors $this->dbh = @new PDO($dsn, Config::read('db.user'), Config::read('db.password'), [PDO::ATTR_PERSISTENT => true]); $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); //PDO::ERRMODE_SILENT $this->dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); $this->query = new QueryHandler(); return $this; }
public function __construct() { $dsn = new MongoClient(); $this->dbh = $dsn->{Config::read('db.name')}; }