Re: native error handling in PEAR::DB drivers
| From: | Tomas V.V.Cox | Date: | Tue, 10 Jun 2003 03:33:48 +0000 |
| Subject: | Re: native error handling in PEAR::DB drivers | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-17238@lists.php.net to get a copy of this message | ||
----- Original Message -----
From: "Roman Neuhauser" <neuhauser@bellavista.cz>
> 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.
Nowadays, the errorNative() functions, are used by the {$DBtype}raiseError()
internaly to set the [userinfo] error message property in the PEAR error
object returned to the user.
What would be cool, would be:
1) to extend the actual DB_error, to store:
DB_error->last_query
DB_error->db_error_code
DB_error->db_error_msg
DB_error->native_error_code
DB_error->native_error_message
DB_error->string_dsn
DB_error->array_dsn
Developers could do then thinks like:
if (PEAR::isError($error = $db->query($sql)) {
die("Error: the query $error->last_query failed due
$error->native_error_msg");
}
2) All the error logic, should be activated (this is included) at error
time, avoiding the include of PEAR.php and extra error discovering code,
enhancing the overall speed of the class.
Tomas V.V.Cox