芝麻web文件管理V1.00
编辑当前文件:/home/strato/chroot/opt/RZphp5/includes/Tree/OptionsDB.php
| // +----------------------------------------------------------------------+ // // $Id: OptionsDB.php,v 1.8.2.4 2009/03/12 17:19:52 dufuz Exp $ require_once 'Tree/Common.php'; /** * this class additionally retreives a DB connection and saves it * in the property "dbh" * * @package Tree * @access public * @author Wolfram Kriesing
* */ class Tree_OptionsDB extends Tree_Common { /** * @var object */ var $dbh; // {{{ Tree_OptionsDB() /** * this constructor sets the options, since i normally need this and * in case the constructor doesnt need to do anymore i already have * it done :-) * * @version 02/01/08 * @access public * @author Wolfram Kriesing
* @param boolean true if loggedIn */ function Tree_OptionsDB($dsn , $options = array()) { $res = $this->_connectDB($dsn); if (PEAR::isError($res)) { return $res; } $this->dbh->setFetchmode(DB_FETCHMODE_ASSOC); // do options afterwards since it overrules $this->Tree_Options($options); } // }}} // {{{ _connectDB() /** * Connect to database by using the given DSN string * * @author copied from PEAR::Auth, Martin Jansen, slightly modified * @access private * @param string DSN string * @return mixed Object on error, otherwise bool */ function _connectDB($dsn) { // only include the db if one really wants to connect require_once 'DB.php'; if (is_string($dsn) || is_array($dsn)) { // put the dsn parameters in an array // DB would be confused with an additional URL-queries, //like ?table=... so we do it before connecting to the DB if (is_string($dsn)) { $dsn = DB::parseDSN($dsn); } $this->dbh = DB::Connect($dsn); } else { if (strtolower(get_parent_class($dsn)) == 'db_common') { $this->dbh = $dsn; } else { if (is_object($dsn) && DB::isError($dsn)) { return new DB_Error($dsn->code, PEAR_ERROR_DIE); } return new PEAR_Error( 'The given dsn was not valid in file '. __FILE__ . " at line " . __LINE__, 41, PEAR_ERROR_RETURN, null, null ); } } if (DB::isError($this->dbh)) { return new DB_Error($this->dbh->code, PEAR_ERROR_DIE); } return true; } // }}} }