function parseDSN($dsn)
 {
     return MDB::parseDSN($dsn);
 }
 /**
  * set the DSN
  *
  * @param mixed     $dsninfo    DSN string or array
  * @return MDB_OK
  * @access public
  */
 function setDSN($dsn)
 {
     $dsninfo = MDB::parseDSN($dsn);
     if (isset($dsninfo['hostspec'])) {
         $this->host = $dsninfo['hostspec'];
     }
     if (isset($dsninfo['port'])) {
         $this->port = $dsninfo['port'];
     }
     if (isset($dsninfo['username'])) {
         $this->user = $dsninfo['username'];
     }
     if (isset($dsninfo['password'])) {
         $this->password = $dsninfo['password'];
     }
     if (isset($dsninfo['database'])) {
         $this->database_name = $dsninfo['database'];
     }
     return MDB_OK;
 }
 /**
  * Returns a MDB connection with the requested DSN.
  * A newnew MDB connection object is only created if no object with the
  * reuested DSN exists yet.
  *
  * 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::sngleton($dsn);
  *          ^^
  * And not:
  *     $mdb = MDB::singleton($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
  */
 function &singleton($dsn = NULL, $options = FALSE)
 {
     if ($dsn) {
         $dsninfo = MDB::parseDSN($dsn);
         $dsninfo_default = array('phptype' => NULL, 'username' => NULL, 'password' => NULL, 'hostspec' => NULL, 'database' => NULL);
         $dsninfo = array_merge($dsninfo_default, $dsninfo);
         $keys = array_keys($GLOBALS['_MDB_databases']);
         for ($i = 0, $j = count($keys); $i < $j; ++$i) {
             $tmp_dsn = $GLOBALS['_MDB_databases'][$keys[$i]]->getDSN('array');
             if ($dsninfo['phptype'] == $tmp_dsn['phptype'] && $dsninfo['username'] == $tmp_dsn['username'] && $dsninfo['password'] == $tmp_dsn['password'] && $dsninfo['hostspec'] == $tmp_dsn['hostspec'] && $dsninfo['database'] == $tmp_dsn['database']) {
                 MDB::setOptions($GLOBALS['_MDB_databases'][$keys[$i]], $options);
                 return $GLOBALS['_MDB_databases'][$keys[$i]];
             }
         }
     } else {
         if (is_array($GLOBALS['_MDB_databases']) && reset($GLOBALS['_MDB_databases'])) {
             $db =& $GLOBALS['_MDB_databases'][key($GLOBALS['_MDB_databases'])];
             return $db;
         }
     }
     $db =& MDB::connect($dsn, $options);
     return $db;
 }