public function buildPDO(array $config=null) {
		if(!$config)
			$config = $this->config;
		$driver = $config['driver'];
		$user = isset($config['user']) ? $config['user']:'root';
		$password = isset($config['password']) ? $config['password']:'';
		$database = isset($config['database']) ? $config['database']:null;

		switch($driver) {
			case 'pgsql':
				$parameters = 'pgsql:host='.$config['host'].(isset($config['port']) ? ' port='.$config['port']:'').($database ? ' dbname='.$database:'');
				$this->pdo = new \PDO($parameters, $user, $password);
				break;
			case 'mssql':
				$parameters = 'mssql:host='.$config['host'].($database ? ';dbname='.$database:'');
				$this->pdo = new \PDO($parameters, $user, $password);
				break;
			case 'sqlite':
				$pdo = $this->pdo = new \PDO('sqlite:'.$database);
	
				require_once __DIR__.'/sqlite_functions.php';

				break;
			default:
				$parameters = 'mysql:host='.$config['host'].(isset($config['port']) ? ';port='.$config['port']:'').($database ? ';dbname='.$database:'');
				$this->pdo = new \PDO($parameters, $user, $password, [\PDO::MYSQL_ATTR_FOUND_ROWS => true, \PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8']);
		}
		$this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
	}
public function buildPDO(array $config=null) {
		if(!$config)
			$config = $this->config;
		$driver = $config['driver'];
		$user = isset($config['user']) ? $config['user']:'root';
		$password = isset($config['password']) ? $config['password']:'';
		$database = isset($config['database']) ? $config['database']:null;

		switch($driver) {
			case 'pgsql':
				$parameters = 'pgsql:host='.$config['host'].(isset($config['port']) ? ' port='.$config['port']:'').($database ? ' dbname='.$database:'');
				$this->pdo = new \PDO($parameters, $user, $password);
				break;
			case 'mssql':
				$parameters = 'mssql:host='.$config['host'].($database ? ';dbname='.$database:'');
				$this->pdo = new \PDO($parameters, $user, $password);
				break;
			case 'sqlite':
				$pdo = $this->pdo = new \PDO('sqlite:'.$database);
	
				require_once __DIR__.'/sqlite_functions.php';

				break;
			default:
				$parameters = 'mysql:host='.$config['host'].(isset($config['port']) ? ';port='.$config['port']:'').($database ? ';dbname='.$database:'');
				$this->pdo = new \PDO($parameters, $user, $password, [\PDO::MYSQL_ATTR_FOUND_ROWS => true, \PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8']);
		}
		$this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
	}
public function buildPDO ( array $ config = null ) { if ( ! $ config ) $ config = $ this -> config ; $ driver = $ config [ 'driver' ] ; $ user = isset ( $ config [ 'user' ] ) ? $ config [ 'user' ] : 'root' ; $ password = isset ( $ config [ 'password' ] ) ? $ config [ 'password' ] : '' ; $ database = isset ( $ config [ 'database' ] ) ? $ config [ 'database' ] : null ; switch ( $ driver ) { case 'pgsql' : $ parameters = 'pgsql:host=' . $ config [ 'host' ] . ( isset ( $ config [ 'port' ] ) ? ' port=' . $ config [ 'port' ] : '' ) . ( $ database ? ' dbname=' . $ database : '' ) ; $ this -> pdo = new \ PDO ( $ parameters , $ user , $ password ) ; break ; case 'mssql' : $ parameters = 'mssql:host=' . $ config [ 'host' ] . ( $ database ? ';dbname=' . $ database : '' ) ; $ this -> pdo = new \ PDO ( $ parameters , $ user , $ password ) ; break ; case 'sqlite' : $ pdo = $ this -> pdo = new \ PDO ( 'sqlite:' . $ database ) ; require_once __DIR__ . '/sqlite_functions.php' ; break ; default : $ parameters = 'mysql:host=' . $ config [ 'host' ] . ( isset ( $ config [ 'port' ] ) ? ';port=' . $ config [ 'port' ] : '' ) . ( $ database ? ';dbname=' . $ database : '' ) ; $ this -> pdo = new \ PDO ( $ parameters , $ user , $ password , [ \ PDO :: MYSQL_ATTR_FOUND_ROWS => true , \ PDO :: MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8' ] ) ; } $ this -> pdo -> setAttribute ( \ PDO :: ATTR_ERRMODE , \ PDO :: ERRMODE_EXCEPTION ) ; }
Build the PDO instance.
@param  array  $config
Build the PDO instance .