/**
  * Create a new MDB2 object for the specified database type
  *
  * IMPORTANT: In order for MDB2 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:
  *     $db =& MDB2::factory($dsn);
  *          ^^
  * And not:
  *     $db = MDB2::factory($dsn);
  *
  * @param   mixed   'data source name', see the MDB2::parseDSN
  *                      method for a description of the dsn format.
  *                      Can also be specified as an array of the
  *                      format returned by MDB2::parseDSN.
  * @param   array   An associative array of option names and
  *                            their values.
  *
  * @return  mixed   a newly created MDB2 object, or false on error
  *
  * @access  public
  */
 static function factory($dsn, $options = false)
 {
     $dsninfo = MDB2::parseDSN($dsn);
     if (empty($dsninfo['phptype'])) {
         $err = MDB2::raiseErrorStatic(MDB2_ERROR_NOT_FOUND, null, null, 'no RDBMS driver specified');
         return $err;
     }
     $class_name = 'MDB2_Driver_' . $dsninfo['phptype'];
     $debug = !empty($options['debug']);
     $err = MDB2::loadClass($class_name, $debug);
     if (PEAR::isError($err)) {
         return $err;
     }
     $db = new $class_name();
     $db->setDSN($dsninfo);
     $err = MDB2::setOptions($db, $options);
     if (PEAR::isError($err)) {
         return $err;
     }
     return $db;
 }