Re: Patch to add odbc_errno(), odbc_error(), odbc_clear_error()
| From: | Andreas Karajannis | Date: | Sun, 05 Nov 2000 11:03:34 +0000 |
| Subject: | Re: Patch to add odbc_errno(), odbc_error(), odbc_clear_error() | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-37163@lists.php.net to get a copy of this message | ||
Lars Torben Wilson wrote:
>
> Hi there,
>
> Following up on difficulties that guys at the office have been having
> (they are moving most DB stuff to ODBC), I've hacked up the following
> three functions into ext/odbc/php_odbc.*:
>
> string odbc_errno(int dbh): Returns 5-char state string from last
> error on the indicated dbh
>
> string odbc_error(int dbh): Returns the text of the last error on
> the indicated dbh
>
> int odbc_clear_error(int dbh): Clears the dbh's last error text &
> sets its state string to "00000".
>
> I didn't know whether there was a globally supported CLI way to do
> this, so I just have PHP keep track of the information by updating 2
> new strings in odbc_connection every time odbc_sql_error() is
> called. I had to add a new parameter to ODBC_SQL_ERROR_PARAMS to pass
> the connection id into odbc_sql_error().
>
What about errors (connecting to a datasource) where you don't have a
connection handle?
>
> It also shuts up the php_error(E_WARNING, ...) from within
> odbc_sql_error(), but that's not really necessary...
>
> Unfortunately I have access ATM only to a MyODBC connection. Could
> someone perhaps take a look at this and see whether it seems like a
> reasonable solution, point out problems, and perhaps mention whether
> there would be quantifiably better way to go about it?
>
How about scrapping odbc_sql_error() if PHP_DEBUG isn't set?
Odbc_err* then could use the CLI SQLError* Functions directly.
The only problem that may arise is that the errors are cleared once they
have been queried (not shure about this), so in PHP_DEBUG mode the
odbc_err* functions wouldn't work.
-Andreas