Esempio n. 1
0
 public function __construct()
 {
     if (is_object(self::$instance)) {
         $this->dbh = self::$instance->dbh;
         return null;
     }
     $config = Init::config('database');
     $dsn = $config['driver'] . ':host=' . $config['hostname'] . ';dbname=' . $config['database'] . ';charset=' . $config['charset'];
     try {
         $this->dbh = new PDO($dsn, $config['username'], $config['password']);
         $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
         $this->dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
         //$this->dbh->query('SET NAMES utf8');
     } catch (PDOException $exc) {
         echo $exc->getMessage();
     }
     self::$instance = $this;
 }
Esempio n. 2
0
 public function __construct()
 {
     $this->uri = new URI();
     var_dump($this->uri->url);
     $this->config = Init::config('application');
 }
Esempio n. 3
0
 /**
  * @return mysqli
  *
  * Conexion a base de datos
  */
 public static function connection()
 {
     self::$config = (require_once 'Config.php');
     $sql = self::$config['connection'];
     return new mysqli($sql['host'], $sql['usr'], $sql['pass'], $sql['db'], $sql['port']);
 }