Re: troubles with db classes
| From: | (Stig Sæther Bakken) | Date: | Mon, 12 Mar 2001 17:45:51 +0000 |
| Subject: | Re: troubles with db classes | ||
| References: | 1 | Groups: | php.pear |
| Request: | Send a blank email to php-pear+get-1805@lists.php.net to get a copy of this message | ||
[Burak DAYIOGLU <dayioglu@metu.edu.tr>]
> Hello,
> I found out the problem at last. The query() method is not implemented
> in the pgsql.php file. So when I call the query method, it is called
> but as no implementation is provided nothing happens (and no error or
> warning is displayed as well). When I try to get count of rows returned
> I get the real error...
None of the DB_<dbtype> classes have the query() method, it's
inherited from DB_common. All the database-specific stuff is in
simpleQuery(), query() is merely a wrapper returning a DB_result
object.
> Wouldn't it be better to give a descriptive error message when numrows()
> is called for a handle which is not valid or not full with some data?
> Stig?
PEAR has an error system that is pretty configurable and that is not
"noisy" by default (printing errors) like PHP is. You can configure
it to, though. Try this:
$dbh = DB::connect($dsn);
$dbh->setErrorHandling(PEAR_ERROR_DIE);
If you only want to print the error message, use PEAR_ERROR_PRINT
instead, or PEAR_ERROR_TRIGGER if you want to use PHP's internal
errors.
- Stig
--
Stig Sæther Bakken <ssb@fast.no>
Fast Search & Transfer ASA, Trondheim, Norway