cvs: pear /Auth/Container DB.php

From: Date: Fri, 16 Nov 2001 21:15:30 +0000
Subject: cvs: pear /Auth/Container DB.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-1348@lists.php.net to get a copy of this message
mj Fri Nov 16 16:15:30 2001 EDT Modified files: /pear/Auth/Container DB.php Log: * Move the connection logic out of the constructor into _connect(). This makes it possible now to pass an already existing PEAR::DB object in the options array. Index: pear/Auth/Container/DB.php diff -u pear/Auth/Container/DB.php:1.7 pear/Auth/Container/DB.php:1.8 --- pear/Auth/Container/DB.php:1.7 Fri Nov 16 16:03:11 2001 +++ pear/Auth/Container/DB.php Fri Nov 16 16:15:30 2001 @@ -16,7 +16,7 @@ // | Authors: Martin Jansen <mj@php.net> | // +----------------------------------------------------------------------+ // -// $Id: DB.php,v 1.7 2001/11/16 21:03:11 mj Exp $ +// $Id: DB.php,v 1.8 2001/11/16 21:15:30 mj Exp $ // require_once "Auth/Container.php"; @@ -30,7 +30,7 @@ * * @author Martin Jansen <mj@php.net> * @package Auth - * @version $Revision: 1.7 $ + * @version $Revision: 1.8 $ */ class Auth_Container_DB extends Auth_Container { @@ -67,30 +67,13 @@ if ($this->options['dsn'] != "") { $this->_connect($this->options['dsn']); + return true; } else { return new DB_Error("No connection parameters specified!"); - } - } else if (is_string($dsn)) { - $this->_connect($dsn); - } - - elseif (is_object($dsn) && DB::isError($dsn)) { - return new DB_Error($dsn->code, PEAR_ERROR_DIE); - } - - // if parent class is db_common, then it's already a connected identifier - elseif (get_parent_class($dsn) == "db_common") { - $this->db = $dsn; - } - - else { - return new PEAR_Error("The given dsn was not valid in file " . __FILE__ . " at line " . __LINE__, - 41, - PEAR_ERROR_RETURN, - null, - null - ); + } } + + $this->_connect($dsn); } // }}} @@ -105,7 +88,21 @@ */ function _connect($dsn) { - $this->db = DB::Connect($dsn); + if (is_string($dsn)) { + $this->db = DB::Connect($dsn); + } elseif (get_parent_class($dsn) == "db_common") { + $this->db = $dsn; + } elseif (is_object($dsn) && DB::isError($dsn)) { + return new DB_Error($dsn->code, PEAR_ERROR_DIE); + } else { + 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->db)) { return new DB_Error($this->db->code, PEAR_ERROR_DIE);

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