private function openConnection($persistent=FALSE) {

		// continue only if not already connected
		if (is_a($this->handler, 'PDO')) {
			return;
		}
		
		switch (DBMS) {
			
			default:
			case 'mysql':
				$dsn = 'mysql:host=' . DB_HOST . ';dbname=' . DB_NAME;
				$options = array(
					\PDO::ATTR_PERSISTENT			=> (bool)$persistent,
					\PDO::MYSQL_ATTR_INIT_COMMAND	=> "SET NAMES utf8",
					\PDO::MYSQL_ATTR_FOUND_ROWS		=> TRUE);
				break;

			case 'mssql':
				$dsn = 'dblib:host=' . DB_HOST . ';dbname=' . DB_NAME;
				$options = [];
				break;
		
		}
		
		try {
				
			$this->handler = new \PDO($dsn, DB_USER, DB_PASS, $options);
				
			if (is_a($this->handler, 'PDO')) {
				$this->handler->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
			} else {
				throw new \PDOException('Db handler is not valid, connection failed');
			}
			
		} catch (\Exception $e) {

			exit($e->getMessage());
			
		}
		
	}
private function openConnection($persistent=FALSE) {

		// continue only if not already connected
		if (is_a($this->handler, 'PDO')) {
			return;
		}
		
		switch (DBMS) {
			
			default:
			case 'mysql':
				$dsn = 'mysql:host=' . DB_HOST . ';dbname=' . DB_NAME;
				$options = array(
					\PDO::ATTR_PERSISTENT			=> (bool)$persistent,
					\PDO::MYSQL_ATTR_INIT_COMMAND	=> "SET NAMES utf8",
					\PDO::MYSQL_ATTR_FOUND_ROWS		=> TRUE);
				break;

			case 'mssql':
				$dsn = 'dblib:host=' . DB_HOST . ';dbname=' . DB_NAME;
				$options = [];
				break;
		
		}
		
		try {
				
			$this->handler = new \PDO($dsn, DB_USER, DB_PASS, $options);
				
			if (is_a($this->handler, 'PDO')) {
				$this->handler->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
			} else {
				throw new \PDOException('Db handler is not valid, connection failed');
			}
			
		} catch (\Exception $e) {

			exit($e->getMessage());
			
		}
		
	}
private function openConnection ( $ persistent = FALSE ) { // continue only if not already connected
 if ( is_a ( $ this -> handler , 'PDO' ) ) { return ; } switch ( DBMS ) { default : case 'mysql' : $ dsn = 'mysql:host=' . DB_HOST . ';dbname=' . DB_NAME ; $ options = array ( \ PDO :: ATTR_PERSISTENT => ( bool ) $ persistent , \ PDO :: MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8" , \ PDO :: MYSQL_ATTR_FOUND_ROWS => TRUE ) ; break ; case 'mssql' : $ dsn = 'dblib:host=' . DB_HOST . ';dbname=' . DB_NAME ; $ options = [ ] ; break ; } try { $ this -> handler = new \ PDO ( $ dsn , DB_USER , DB_PASS , $ options ) ; if ( is_a ( $ this -> handler , 'PDO' ) ) { $ this -> handler -> setAttribute ( \ PDO :: ATTR_ERRMODE , \ PDO :: ERRMODE_EXCEPTION ) ; } else { throw new \ PDOException ( 'Db handler is not valid, connection failed' ) ; } } catch ( \ Exception $ e ) { exit ( $ e -> getMessage ( ) ) ; } }
Connects to DBMS with params only if PDO handler property is null, so not connected.

@param	bool	Flag to open a persistent connection (TRUE). Default is FALSE.

@throws	PDOException
Connects to DBMS with params only if PDO handler property is null so not connected .