/** * Convert data source config to DSN object * * @param array data source config * @return LazyRecord\DSN\DSN */ public static function buildDSNObject(array $config) { // Build DSN connection string for PDO $dsn = new DSN($config['driver']); foreach (array('database', 'dbname') as $key) { if (isset($config[$key])) { $dsn->setAttribute('dbname', $config[$key]); break; } } if (isset($config['host'])) { $dsn->setAttribute('host', $config['host']); } if (isset($config['port'])) { $dsn->setAttribute('port', $config['port']); } return $dsn; }