Exemple #1
0
 /**
  * Create a new connection
  *
  * @param array $cfg config
  */
 public static function connect(array $cfg)
 {
     self::$config = $cfg;
     self::checkConfig($cfg);
     try {
         self::$con = new PDO($cfg['driver'] . ":host=" . $cfg['hostname'] . ";charset=" . $cfg['charset'], $cfg['username'], $cfg['password'], array(PDO::MYSQL_ATTR_LOCAL_INFILE => true, PDO::ATTR_TIMEOUT => 60, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
     } catch (PDOException $e) {
         throw new Exceptions\DataBaseException("You can't connect to the host: " . $e->getMessage());
     }
     self::select($cfg['database']);
     switch ($cfg['driver']) {
         case 'mysql':
             self::$sql = 'MYSQL';
             break;
     }
     Schema::ini();
     if ($cfg['restore'] > 0) {
         self::iniRestore();
     }
     self::startLog();
     static::$log = [];
 }