Re: native error handling in PEAR::DB drivers
| From: | Martin Jansen | Date: | Mon, 09 Jun 2003 16:57:35 +0000 |
| Subject: | Re: native error handling in PEAR::DB drivers | ||
| References: | 1 2 3 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-17214@lists.php.net to get a copy of this message | ||
On Mon Jun 09, 2003 at 06:1619PM +0200, Roman Neuhauser wrote:
> # jon@php.net / 2003-06-09 11:48:30 -0400:
> > On Mon, Jun 09, 2003 at 01:12:53PM +0200, Roman Neuhauser wrote:
> >
> > > these are the bases of errorNative() methods of individual drivers:
> > >
> > > DB/fbsql.php : fbsql_errno()
> > > DB/ibase.php : -
> > > DB/ifx.php : ifx_error() . ' ' . ifx_errormsg()
> > > DB/msql.php : -
> > > DB/mssql.php : -
> > > DB/mysql.php : mysql_errno()
> > > DB/mysql4.php : mysql_errno()
> > > DB/oci8.php : OCIError()['code']
> > > DB/odbc.php : odbc_error() . ' ' . odbc_errormsg()
> > > DB/pgsql.php : pg_errormessage()
> > > DB/sybase.php : sybase_get_last_message()
> > >
> > > shouldnn't they all behave the same, returning either the number or the
> > > text? I'd like to push some of the code up to the parent (DB::common),
> > > but these trivial differences make it problematic.
> >
> > I think the lowest common denominator is going to be the error code,
> > and it makes sense that all of the errorNative() calls should return a
> > consistent type of error.
> >
> > Perhaps errorNative() could grow an optional parameter ($verbose?)
> > that would indicate that the caller was also interested in the error
> > text (if available), as well?
Sounds like a good idea.
> This is a bit complicated as I don't know the error message format
> of all the databases, or other ways of getting at the codes.
We should at least try to have a consistent behaviour for most
databases. And we'll surely find someone, who knows how to get the
error-code or the -message for database XYZ.
> For example, a user note at
>
> http://www.php.net/manual/en/function.mssql-get-last-message.php
> states that you can get the code from SELECT @@ERROR. This would
> make the mssql driver more compatible with the rest, but would this
> be welcome?
Sounds good.
--
- Martin Martin Jansen
http://martinjansen.com/