irm/lib/MDB.php
/**
     * Create a new MDB connection object and connect to the specified
     * database
     *
     * IMPORTANT: In order for MDB to work properly it is necessary that
     * you make sure that you work with a reference of the original
     * object instead of a copy (this is a PHP4 quirk).
     *
     * For example:
     *     $mdb =& MDB::connect($dsn);
     *          ^^
     * And not:
     *     $mdb = MDB::connect($dsn);
     *          ^^
     *
     * @param   mixed   $dsn      'data source name', see the MDB::parseDSN
     *                            method for a description of the dsn format.
     *                            Can also be specified as an array of the
     *                            format returned by MDB::parseDSN.
     * @param   mixed   $options  An associative array of option names and
     *                            their values.
     * @return  mixed   a newly created MDB connection object, or a MDB
     *                  error object on error
     * @access  public
     * @see     MDB::parseDSN
     */
Create a new MDB connection object and connect to the specified
database

In order for MDB to work properly it is necessary that
you make sure that you work with a reference of the original
object instead of a copy (this is a PHP4 quirk).



@param   mixed   $dsn      'data source name', see the MDB::parseDSN
method for a description of the dsn format.
Can also be specified as an array of the
format returned by MDB::parseDSN.
@param   mixed   $options  An associative array of option names and
their values.
@return  mixed   a newly created MDB connection object, or a MDB
error object on error
@access  public
@see     MDB::parseDSN
Create a new MDB connection object and connect to the specified database In order for MDB to work properly it is necessary that you make sure that you work with a reference of the original object instead of a copy ( this is a PHP4 quirk ) . @param mixed $dsn ' data source name ' see the MDB :: parseDSN method for a description of the dsn format . Can also be specified as an array of the format returned by MDB :: parseDSN . @param mixed $options An associative array of option names and their values . @return mixed a newly created MDB connection object or a MDB error object on error @access public @see MDB :: parseDSN
function &connect($dsn, $options = FALSE)
    {
        $dsninfo = MDB::parseDSN($dsn);
        if(isset($dsninfo['phptype'])) {
            $type          = $dsninfo['phptype'];
            $class_name    = 'MDB_'.$type;
            $include       = 'MDB/'.$type.'.php';
        } else {
            return(PEAR::raiseError(NULL, MDB_ERROR_NOT_FOUND,
                NULL, NULL, 'no RDBMS driver specified',
                'MDB_Error', TRUE));
        }
        if(is_array($options)
            && isset($options['debug'])
            && $options['debug'] >= 2
        ) {
            @include_once($include);
        } else {
            include_once($include);
        }
        if(!class_exists($class_name)) {
            $error = PEAR::raiseError(NULL, MDB_ERROR_NOT_FOUND, NULL, NULL,
                'Unable to include the '.$include.' file', 'MDB_Error', TRUE);
            return($error);
        }
        @$db = new $class_name();
        $db->setDSN($dsninfo);
        MDB::setOptions($db, $options);
        if(isset($dsninfo['database'])) {
            $err = $db->connect();
            if (MDB::isError($err)) {
                $dsn = $db->getDSN();
                $err->addUserInfo($dsn);
                return($err);
            }
        }
        return($db);
    }
function & connect ( $ dsn , $ options = FALSE ) { $ dsninfo = MDB :: parseDSN ( $ dsn ) ; if ( isset ( $ dsninfo [ 'phptype' ] ) ) { $ type = $ dsninfo [ 'phptype' ] ; $ class_name = 'MDB_' . $ type ; $ include = 'MDB/' . $ type . '.php' ; } else { return ( PEAR :: raiseError ( NULL , MDB_ERROR_NOT_FOUND , NULL , NULL , 'no RDBMS driver specified' , 'MDB_Error' , TRUE ) ) ; } if ( is_array ( $ options ) && isset ( $ options [ 'debug' ] ) && $ options [ 'debug' ] >= 2 ) { @ include_once ( $ include ) ; } else { include_once ( $ include ) ; } if ( ! class_exists ( $ class_name ) ) { $ error = PEAR :: raiseError ( NULL , MDB_ERROR_NOT_FOUND , NULL , NULL , 'Unable to include the ' . $ include . ' file' , 'MDB_Error' , TRUE ) ; return ( $ error ) ; } @ $ db = new $ class_name ( ) ; $ db -> setDSN ( $ dsninfo ) ; MDB :: setOptions ( $ db , $ options ) ; if ( isset ( $ dsninfo [ 'database' ] ) ) { $ err = $ db -> connect ( ) ; if ( MDB :: isError ( $ err ) ) { $ dsn = $ db -> getDSN ( ) ; $ err -> addUserInfo ( $ dsn ) ; return ( $ err ) ; } } return ( $ db ) ; }
Create a new MDB connection object and connect to the specified
 database
Create a new MDB connection object and connect to the specified database
// expose php errors with sufficient debug level