Re: Auth DB container prolems
| From: | Yavor Shahpasov | Date: | Mon, 17 Mar 2003 12:18:51 +0000 |
| Subject: | Re: Auth DB container prolems | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-14358@lists.php.net to get a copy of this message | ||
Sorry here it comes again
Yavor
----- Original Message -----
From: "Roman Neuhauser" <neuhauser@bellavista.cz>
To: "Yavor Shahpasov" <yavo@siava.org>
Cc: <pear-dev@lists.php.net>
Sent: Monday, March 17, 2003 1:55 PM
Subject: Re: [PEAR-DEV] Auth DB container prolems
> # yavo@siava.org / 2003-03-17 13:55:31 +0200:
> > Find attahched a patch which deals with some error handing in the DB
> > container.
>
> ...
>
> > --- DB.php Mon Mar 17 13:50:29 2003
> > +++ DB.php.orig Mon Mar 17 13:48:53 2003
> > @@ -107,7 +107,7 @@
> >
> > }
> >
> > - if (DB::isError($this->db) || PEAR::isError($this->db)) {
> > + if (DB::isError($this->db)) {
>
> the patch is backwards.
>
> --
> If you cc me or remove the list(s) completely I'll most likely ignore
> your message. see
> http://www.eyrie.org./~eagle/faqs/questions.html
>
--- DB.php.orig Mon Mar 17 13:48:53 2003 +++ DB.php Mon Mar 17 14:18:02 2003 @@ -46,7 +46,7 @@ * @var object */ var $db = null; - var $dsn = ""; + var $dsn = null; /** * User that is currently selected from the DB. @@ -107,7 +107,7 @@ } - if (DB::isError($this->db)) { + if (DB::isError($this->db) || PEAR::isError($this->db)) { return PEAR::raiseError("", $this->db->code, PEAR_ERROR_DIE); } else { return true; @@ -131,7 +131,10 @@ function query($query) { if (!DB::isConnection($this->db)) { - $this->_connect($this->options['dsn']); + $res = $this->_connect($this->options['dsn']); + if(DB::isError($res) || PEAR::isError($res)){ + return($res); + } } return $this->db->query($query); } @@ -149,7 +152,7 @@ $this->options['table'] = "auth"; $this->options['usernamecol'] = "username"; $this->options['passwordcol'] = "password"; - $this->options['dsn'] = ""; + //$this->options['dsn'] = ""; $this->options['db_fields'] = "*"; $this->options['cryptType'] = "md5"; } @@ -209,8 +212,8 @@ $res = $this->query($query); - if (DB::isError($res)) { - return PEAR::raiseError("", $res->code, PEAR_ERROR_DIE); + if (DB::isError($res) || PEAR::isError($res)) { + return PEAR::raiseError($res->getMessage(), $res->code, PEAR_ERROR_DIE); } else { $entry = $res->fetchRow(DB_FETCHMODE_ASSOC);
--- DB.php.orig Mon Mar 17 13:48:53 2003 +++ DB.php Mon Mar 17 14:18:02 2003 @@ -46,7 +46,7 @@ * @var object */ var $db = null; - var $dsn = ""; + var $dsn = null; /** * User that is currently selected from the DB. @@ -107,7 +107,7 @@ } - if (DB::isError($this->db)) { + if (DB::isError($this->db) || PEAR::isError($this->db)) { return PEAR::raiseError("", $this->db->code, PEAR_ERROR_DIE); } else { return true; @@ -131,7 +131,10 @@ function query($query) { if (!DB::isConnection($this->db)) { - $this->_connect($this->options['dsn']); + $res = $this->_connect($this->options['dsn']); + if(DB::isError($res) || PEAR::isError($res)){ + return($res); + } } return $this->db->query($query); } @@ -149,7 +152,7 @@ $this->options['table'] = "auth"; $this->options['usernamecol'] = "username"; $this->options['passwordcol'] = "password"; - $this->options['dsn'] = ""; + //$this->options['dsn'] = ""; $this->options['db_fields'] = "*"; $this->options['cryptType'] = "md5"; } @@ -209,8 +212,8 @@ $res = $this->query($query); - if (DB::isError($res)) { - return PEAR::raiseError("", $res->code, PEAR_ERROR_DIE); + if (DB::isError($res) || PEAR::isError($res)) { + return PEAR::raiseError($res->getMessage(), $res->code, PEAR_ERROR_DIE); } else { $entry = $res->fetchRow(DB_FETCHMODE_ASSOC);