Example #1
0
 /**
  * @param QuarkURI $uri
  *
  * @return mixed
  *
  * @throws QuarkConnectionException
  */
 public function Connect(QuarkURI $uri)
 {
     $this->_connection = \pg_connect('host=\'' . $uri->host . '\'' . 'port=\'' . $uri->port . '\'' . 'dbname=\'' . QuarkSQL::DBName($uri->path) . '\'' . 'user=\'' . $uri->user . '\'' . 'password=\'' . $uri->pass . '\'' . 'options=\'' . $uri->options . '\'');
     if (!$this->_connection) {
         throw new QuarkConnectionException($uri, Quark::LOG_FATAL);
     }
     $this->_sql = new QuarkSQL($this);
 }
Example #2
0
 /**
  * @param QuarkURI $uri
  *
  * @return mixed
  *
  * @throws QuarkArchException
  * @throws QuarkConnectionException
  */
 public function Connect(QuarkURI $uri)
 {
     $this->_connection = \mysqli_init();
     if (!$this->_connection) {
         throw new QuarkArchException('MySQLi initialization fault');
     }
     $options = $uri->options;
     if (is_array($options)) {
         foreach ($options as $key => $value) {
             if (!$this->_connection->options($key, $value)) {
                 throw new QuarkArchException('MySQLi option set error');
             }
         }
     }
     if (!$this->_connection->real_connect($uri->host, $uri->user, $uri->pass, QuarkSQL::DBName($uri->path), (int) $uri->port)) {
         throw new QuarkConnectionException($uri, Quark::LOG_FATAL);
     }
     $this->_sql = new QuarkSQL($this);
 }