Re: cvs: php4 /pear DB.php
| From: | David Croft | Date: | Wed, 26 Jul 2000 10:12:58 +0000 |
| Subject: | Re: cvs: php4 /pear DB.php | ||
| References: | 1 | Groups: | php.pear |
| Request: | Send a blank email to php-pear+get-167@lists.php.net to get a copy of this message | ||
Out of interest, can a constructor return false to have the "new" call
return false? Or is there any way of achieving this?
I was wondering about this when I added the if extension_loaded to the
constructor of Payment_Verisign
David.
On Wed, 26 Jul 2000, Stig Bakken wrote:
> ssb Wed Jul 26 02:57:06 2000 EDT
>
> Modified files:
> /php4/pear DB.php
> Log:
> Multiple DB::connect or DB::factory calls using the same backend
> should work now.
>
>
> Index: php4/pear/DB.php
> diff -u php4/pear/DB.php:1.24 php4/pear/DB.php:1.25
> --- php4/pear/DB.php:1.24 Mon Jul 24 01:24:14 2000
> +++ php4/pear/DB.php Wed Jul 26 02:57:06 2000
> @@ -17,7 +17,7 @@
> // | |
> // +----------------------------------------------------------------------+
> //
> -// $Id: DB.php,v 1.24 2000/07/24 08:24:14 ssb Exp $
> +// $Id: DB.php,v 1.25 2000/07/26 09:57:06 ssb Exp $
> //
> // Database independent query interface.
> //
> @@ -163,11 +163,12 @@
> * error
> */
> function &factory($type) {
> - if (!@include_once("DB/${type}.php")) {
> - return DB_ERROR_NOT_FOUND;
> - }
> + @include_once("DB/${type}.php");
> $classname = 'DB_' . $type;
> - $obj = new $classname;
> + $obj = @new $classname;
> + if (!$obj) {
> + return new DB_Error(DB_ERROR_NOT_FOUND);
> + }
> return $obj;
> }
>
> @@ -192,11 +193,12 @@
>
> $dsninfo = DB::parseDSN($dsn);
> $type = $dsninfo['phptype'];
> - if (!@include_once("DB/${type}.php")) {
> - return DB_ERROR_NOT_FOUND;
> - }
> + @include_once("DB/${type}.php");
> $classname = 'DB_' . $type;
> - $obj = new $classname;
> + $obj = @new $classname;
> + if (!$obj) {
> + return new DB_Error(DB_ERROR_NOT_FOUND);
> + }
> $err = $obj->connect(&$dsninfo, $persistent);
> if (DB::isError($err)) {
> return $err;
>
>
>
>
--
|> /+\ \| | |>