<?php
include_once(PHPLENS_DIR."/config/phplens.config.inc.php");
function &LensDBConnection($dbid,$persist=true)
{
global $PHPLENS_DATABASES;

	$fn = ($persist) ? 'PConnect' : 'Connect';
	$DB =& ADONewConnection($PHPLENS_DATABASES[$dbid][0]);
	//----------------------------------------------
	// PConnect - server, userid, password, database
	if (!$DB->$fn($PHPLENS_DATABASES[$dbid][1],
                        $PHPLENS_DATABASES[$dbid][2],
                        $PHPLENS_DATABASES[$dbid][3],
                        $PHPLENS_DATABASES[$dbid][4])) {
		$msg = $DB->ErrorMsg();
		$DB = false;
		LensDie("Connect error to {$PHPLENS_DATABASES[$dbid][1]}",LENSERROR_SEVERE,$msg);
	}
	return $DB;
}

function &LensDBConnectionPersist($dbid)
{
	return LensDBConnection($dbid,true);
}

?>
