public function connect() {
		mysqli_report(MYSQLI_REPORT_STRICT);
		$settings = parse_url($this->dsn);

		// If we can't even parse the DSN, don't bother
		if (!isset($settings['path']) OR !isset($settings['host']) OR !isset($settings['user'])) {
			throw new \Exception('Could not connect to database: DSN incorrect');
		}

		// We don't support connecting to UNIX sockets the traditional way
		if ($settings['host'] == 'unix(') {
			throw new \Exception('Could not connect to database: UNIX socket syntax is wrong');
		}

		$settings['path'] = substr($settings['path'], 1);
		$this->database = @new \Mysqli($settings['host'], $settings['user'], $settings['pass'], $settings['path']);

		// If there is an error connecting to the database, stop doing what you're doing
		if ($this->database->connect_errno != 0) {
			throw new \Exception('Could not connect to database: ' . $this->database->connect_error);
		}

		$this->database->set_charset('utf8');
		$this->connected = true;
	}
public function connect() {
		mysqli_report(MYSQLI_REPORT_STRICT);
		$settings = parse_url($this->dsn);

		// If we can't even parse the DSN, don't bother
		if (!isset($settings['path']) OR !isset($settings['host']) OR !isset($settings['user'])) {
			throw new \Exception('Could not connect to database: DSN incorrect');
		}

		// We don't support connecting to UNIX sockets the traditional way
		if ($settings['host'] == 'unix(') {
			throw new \Exception('Could not connect to database: UNIX socket syntax is wrong');
		}

		$settings['path'] = substr($settings['path'], 1);
		$this->database = @new \Mysqli($settings['host'], $settings['user'], $settings['pass'], $settings['path']);

		// If there is an error connecting to the database, stop doing what you're doing
		if ($this->database->connect_errno != 0) {
			throw new \Exception('Could not connect to database: ' . $this->database->connect_error);
		}

		$this->database->set_charset('utf8');
		$this->connected = true;
	}
public function connect ( ) { mysqli_report ( MYSQLI_REPORT_STRICT ) ; $ settings = parse_url ( $ this -> dsn ) ; // If we can't even parse the DSN, don't bother if ( ! isset ( $ settings [ 'path' ] ) OR ! isset ( $ settings [ 'host' ] ) OR ! isset ( $ settings [ 'user' ] ) ) { throw new \ Exception ( 'Could not connect to database: DSN incorrect' ) ; } // We don't support connecting to UNIX sockets the traditional way if ( $ settings [ 'host' ] == 'unix(' ) { throw new \ Exception ( 'Could not connect to database: UNIX socket syntax is wrong' ) ; } $ settings [ 'path' ] = substr ( $ settings [ 'path' ] , 1 ) ; $ this -> database = @ new \ Mysqli ( $ settings [ 'host' ] , $ settings [ 'user' ] , $ settings [ 'pass' ] , $ settings [ 'path' ] ) ; // If there is an error connecting to the database, stop doing what you're doing if ( $ this -> database -> connect_errno != 0 ) { throw new \ Exception ( 'Could not connect to database: ' . $ this -> database -> connect_error ) ; } $ this -> database -> set_charset ( 'utf8' ) ; $ this -> connected = true ; }
Connect to the database by providing a DSN

@access public
@param string $dsn The database source name you want to connect to
@throws Exception Throws an Exception when the Database is unavailable
Connect to the database by providing a DSN