function connect($dsn, $options = false)
	{
		if (is_array($dsn)) {
			$dsninfo = $dsn;
		} else {
			$dsninfo = DB::parseDSN($dsn);
		}
		switch ($dsninfo["phptype"]) {
			case 'pgsql': 	$type = 'postgres7'; break;
			case 'ifx':		$type = 'informix9'; break;
			default: 		$type = $dsninfo["phptype"]; break;
		}

		if (is_array($options) && isset($options["debug"]) &&
			$options["debug"] >= 2) {
			// expose php errors with sufficient debug level
			 @include_once("adodb-$type.inc.php");
		} else {
			 @include_once("adodb-$type.inc.php");
		}

		@$obj = NewADOConnection($type);
		if (!is_object($obj)) {
			$obj = new PEAR_Error('Unknown Database Driver: '.$dsninfo['phptype'],-1);
			return $obj;
		}
		if (is_array($options)) {
			foreach($options as $k => $v) {
				switch(strtolower($k)) {
				case 'persist':
				case 'persistent': 	$persist = $v; break;
				#ibase
				case 'dialect': 	$obj->dialect = $v; break;
				case 'charset':		$obj->charset = $v; break;
				case 'buffers':		$obj->buffers = $v; break;
				#ado
				case 'charpage':	$obj->charPage = $v; break;
				#mysql
				case 'clientflags': $obj->clientFlags = $v; break;
				}
			}
		} else {
		   	$persist = false;
		}

		if (isset($dsninfo['socket'])) $dsninfo['hostspec'] .= ':'.$dsninfo['socket'];
		else if (isset($dsninfo['port'])) $dsninfo['hostspec'] .= ':'.$dsninfo['port'];

		if($persist) $ok = $obj->PConnect($dsninfo['hostspec'], $dsninfo['username'],$dsninfo['password'],$dsninfo['database']);
		else  $ok = $obj->Connect($dsninfo['hostspec'], $dsninfo['username'],$dsninfo['password'],$dsninfo['database']);

		if (!$ok) $obj = ADODB_PEAR_Error();
		return $obj;
	}
function connect($dsn, $options = false)
	{
		if (is_array($dsn)) {
			$dsninfo = $dsn;
		} else {
			$dsninfo = DB::parseDSN($dsn);
		}
		switch ($dsninfo["phptype"]) {
			case 'pgsql': 	$type = 'postgres7'; break;
			case 'ifx':		$type = 'informix9'; break;
			default: 		$type = $dsninfo["phptype"]; break;
		}

		if (is_array($options) && isset($options["debug"]) &&
			$options["debug"] >= 2) {
			// expose php errors with sufficient debug level
			 @include_once("adodb-$type.inc.php");
		} else {
			 @include_once("adodb-$type.inc.php");
		}

		@$obj = NewADOConnection($type);
		if (!is_object($obj)) {
			$obj = new PEAR_Error('Unknown Database Driver: '.$dsninfo['phptype'],-1);
			return $obj;
		}
		if (is_array($options)) {
			foreach($options as $k => $v) {
				switch(strtolower($k)) {
				case 'persist':
				case 'persistent': 	$persist = $v; break;
				#ibase
				case 'dialect': 	$obj->dialect = $v; break;
				case 'charset':		$obj->charset = $v; break;
				case 'buffers':		$obj->buffers = $v; break;
				#ado
				case 'charpage':	$obj->charPage = $v; break;
				#mysql
				case 'clientflags': $obj->clientFlags = $v; break;
				}
			}
		} else {
		   	$persist = false;
		}

		if (isset($dsninfo['socket'])) $dsninfo['hostspec'] .= ':'.$dsninfo['socket'];
		else if (isset($dsninfo['port'])) $dsninfo['hostspec'] .= ':'.$dsninfo['port'];

		if($persist) $ok = $obj->PConnect($dsninfo['hostspec'], $dsninfo['username'],$dsninfo['password'],$dsninfo['database']);
		else  $ok = $obj->Connect($dsninfo['hostspec'], $dsninfo['username'],$dsninfo['password'],$dsninfo['database']);

		if (!$ok) $obj = ADODB_PEAR_Error();
		return $obj;
	}
function connect ( $ dsn , $ options = false ) { if ( is_array ( $ dsn ) ) { $ dsninfo = $ dsn ; } else { $ dsninfo = DB :: parseDSN ( $ dsn ) ; } switch ( $ dsninfo [ "phptype" ] ) { case 'pgsql' : $ type = 'postgres7' ; break ; case 'ifx' : $ type = 'informix9' ; break ; default : $ type = $ dsninfo [ "phptype" ] ; break ; } if ( is_array ( $ options ) && isset ( $ options [ "debug" ] ) && $ options [ "debug" ] >= 2 ) { // expose php errors with sufficient debug level @ include_once ( "adodb-$type.inc.php" ) ; } else { @ include_once ( "adodb-$type.inc.php" ) ; } @ $ obj = NewADOConnection ( $ type ) ; if ( ! is_object ( $ obj ) ) { $ obj = new PEAR_Error ( 'Unknown Database Driver: ' . $ dsninfo [ 'phptype' ] , - 1 ) ; return $ obj ; } if ( is_array ( $ options ) ) { foreach ( $ options as $ k => $ v ) { switch ( strtolower ( $ k ) ) { case 'persist' : case 'persistent' : $ persist = $ v ; break ; #ibase case 'dialect' : $ obj -> dialect = $ v ; break ; case 'charset' : $ obj -> charset = $ v ; break ; case 'buffers' : $ obj -> buffers = $ v ; break ; #ado case 'charpage' : $ obj -> charPage = $ v ; break ; #mysql case 'clientflags' : $ obj -> clientFlags = $ v ; break ; } } } else { $ persist = false ; } if ( isset ( $ dsninfo [ 'socket' ] ) ) $ dsninfo [ 'hostspec' ] .= ':' . $ dsninfo [ 'socket' ] ; else if ( isset ( $ dsninfo [ 'port' ] ) ) $ dsninfo [ 'hostspec' ] .= ':' . $ dsninfo [ 'port' ] ; if ( $ persist ) $ ok = $ obj -> PConnect ( $ dsninfo [ 'hostspec' ] , $ dsninfo [ 'username' ] , $ dsninfo [ 'password' ] , $ dsninfo [ 'database' ] ) ; else $ ok = $ obj -> Connect ( $ dsninfo [ 'hostspec' ] , $ dsninfo [ 'username' ] , $ dsninfo [ 'password' ] , $ dsninfo [ 'database' ] ) ; if ( ! $ ok ) $ obj = ADODB_PEAR_Error ( ) ; return $ obj ; }
Create a new DB object and connect to the specified database

@param $dsn mixed "data source name", see the DB::parseDSN
method for a description of the dsn format.  Can also be
specified as an array of the format returned by DB::parseDSN.

@param $options mixed if boolean (or scalar), tells whether
this connection should be persistent (for backends that support
this).  This parameter can also be an array of options, see
DB_common::setOption for more information on connection
options.

@return object a newly created DB connection object, or a DB
error object on error

@see DB::parseDSN
@see DB::isError
Create a new DB object and connect to the specified database