cvs: pear /MDB MDB.php /MDB/MDB Common.php

From: Date: Sun, 23 Mar 2003 17:24:08 +0000
Subject: cvs: pear /MDB MDB.php /MDB/MDB Common.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-9589@lists.php.net to get a copy of this message
lsmith Sun Mar 23 12:24:08 2003 EDT Modified files: /pear/MDB MDB.php /pear/MDB/MDB Common.php Log: improvements to getDSN and setDSN Index: pear/MDB/MDB.php diff -u pear/MDB/MDB.php:1.53 pear/MDB/MDB.php:1.54 --- pear/MDB/MDB.php:1.53 Sat Mar 22 18:44:30 2003 +++ pear/MDB/MDB.php Sun Mar 23 12:24:03 2003 @@ -42,7 +42,7 @@ // | Author: Lukas Smith <smith@backendmedia.com> | // +----------------------------------------------------------------------+ // -// $Id: MDB.php,v 1.53 2003/03/22 23:44:30 lsmith Exp $ +// $Id: MDB.php,v 1.54 2003/03/23 17:24:03 lsmith Exp $ // require_once('PEAR.php'); @@ -210,7 +210,7 @@ * MDB_Manager This class handles the xml schema management. * * @package MDB - * @version $Id: MDB.php,v 1.53 2003/03/22 23:44:30 lsmith Exp $ + * @version $Id: MDB.php,v 1.54 2003/03/23 17:24:03 lsmith Exp $ * @category Database * @author Lukas Smith <smith@backendmedia.com> */ @@ -325,7 +325,6 @@ $db->captureDebugOutput(TRUE); } if(isset($dsninfo['database'])) { - $db->setDatabase($dsninfo['database']); $err = $db->connect(); if (MDB::isError($err)) { $dsn = $db->getDSN(); Index: pear/MDB/MDB/Common.php diff -u pear/MDB/MDB/Common.php:1.96 pear/MDB/MDB/Common.php:1.97 --- pear/MDB/MDB/Common.php:1.96 Sat Mar 22 18:44:30 2003 +++ pear/MDB/MDB/Common.php Sun Mar 23 12:24:05 2003 @@ -42,7 +42,7 @@ // | Author: Lukas Smith <smith@backendmedia.com> | // +----------------------------------------------------------------------+ // -// $Id: Common.php,v 1.96 2003/03/22 23:44:30 lsmith Exp $ +// $Id: Common.php,v 1.97 2003/03/23 17:24:05 lsmith Exp $ /** * @package MDB @@ -737,6 +737,9 @@ if(isset($dsninfo['password'])) { $this->password = $dsninfo['password']; } + if(isset($dsninfo['database'])) { + $this->database_name = $dsninfo['database']; + } return(MDB_OK); } @@ -746,15 +749,30 @@ /** * return the DSN as a string * - * @return string DSN + * @param string $type type to return + * @return mixed DSN in the chosen type * @access public */ - function getDSN() + function getDSN($type = 'string') { - return($this->phptype.'://'.$this->user.':' - .$this->password.'@'.$this->host - .(isset($this->port) ? (':'.$this->port) : '') - .'/'.$this->database_name); + switch($type) { + case 'array': + $dsn = array( + 'phptype' => $this->phptype, + 'username' => $this->user, + 'password' => $this->password, + 'hostspec' => $this->host, + 'database' => $this->database_name + ); + break; + default: + $dsn = $this->phptype.'://'.$this->user.':' + .$this->password.'@'.$this->host + .(isset($this->port) ? (':'.$this->port) : '') + .'/'.$this->database_name; + break; + } + return($dsn); } // }}}

« previous php.pear.cvs (#9589) next »