Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class MySQlDB {
- private $user;
- private $pass;
- private $host;
- private $base;
- private $file;
- public $pdo;
- public function __construct(){
- try{
- $this->user = 'root';
- $this->pass = '';
- $this->host = 'localhost';
- $this->base = 'benedelle'; //benedelle
- $params = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES UTF8');
- $this->file = 'mysql:host='.$this->host.';dbname='.$this->base;
- $this->pdo = new PDO($this->file, $this->user, $this->pass, $params);
- $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $this->pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
- $this->pdo->setAttribute(PDO::ATTR_PERSISTENT, true);
- if(!$this->pdo){
- echo "Erro na conexão com o Banco de Dados";
- }
- return $this->pdo;
- }catch(PDOException $ex){
- echo "Erro no sistema: " . $ex->getMessage()."<br>";
- }
- }
- /* Constante para Acessar de Outras Classes
- * @CONSTANT
- */
- public static $system = 'solid_'; //CONSTANTE
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement