예제 #1
0
파일: Mysql.php 프로젝트: thupan/framework
 public function connect($connection, $database, $host, $port, $username, $password)
 {
     self::$config = autoload_config();
     // rename
     $current = $connection;
     try {
         $this->connection[$current] = new \PDO("mysql:host={$host};dbname={$database};charset=UTF8", $username, $password);
         $this->connection[$current]->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
         Debug::collectorPDO($this->connection[$current]);
     } catch (PDOException $e) {
         self::$error[] = $e->getMessage();
         Debug::getInstance('exceptions')->addException($e);
     }
     return $this;
 }
예제 #2
0
파일: Oci.php 프로젝트: thupan/framework
 public function connect($connection, $database, $host, $port, $username, $password)
 {
     self::$config = autoload_config();
     // rename
     $current = $connection;
     try {
         $tns = "(DESCRIPTION =\n                        (ADDRESS_LIST =\n                            (ADDRESS = (PROTOCOL = TCP)(HOST = {$host})(PORT = {$port}))\n                        )\n                        (CONNECT_DATA =\n                            (SERVICE_NAME = {$database})\n                        )\n                    )";
         $this->connection[$current] = new \PDO("oci:dbname={$tns};charset=UTF8", $username, $password);
         $this->connection[$current]->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
         if ($nls = self::$config['database']['DB_OCI_NLS']) {
             foreach ($nls as $key => $value) {
                 self::$config['database']['DB_OCI_NLS'][$key] ? $this->connection[$current]->exec("ALTER SESSION set {$key}='{$value}'") : false;
             }
         }
         Debug::collectorPDO($this->connection[$current]);
     } catch (PDOException $e) {
         self::$error[] = $e->getMessage();
         Debug::getInstance('exceptions')->addException($e);
     }
     return $this;
 }