Re: Patch to add odbc_errno(), odbc_error(), odbc_clear_error()
| From: | Lars Torben Wilson | Date: | Sun, 05 Nov 2000 22:19:44 +0000 |
| Subject: | Re: Patch to add odbc_errno(), odbc_error(), odbc_clear_error() | ||
| References: | 1 2 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-37208@lists.php.net to get a copy of this message | ||
Andreas Karajannis writes:
> > 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?
I had originally thought about maintaining a global hash of the error
states & strings instead of having them part of the connection
handle--but that got into a whole bunch of thread-safety weirdness
and just seemed like a lot of code to do a simple thing.
One idea would be that if i.e. odbc_errno() is called without a $dbh,
it would directly use SQLError() to find the last error to have
occurred at all.
> > 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
I tried that--I just called SQLError() on the passed $dbh right from
odbc_error(), and found that I kept getting information about the
'wrong' operation. That is, I would get information about the last CLI
operation to have occurred, which wasn't always the same as the last
PHP-level operation to have occurred. ODBC wizards might want
information about that, but it was just confusing to me. (For
instance, I executed a query with invalid syntax and called it: it
told me "01S02: Option changed."
--
+----------------------------------------------------------------+
|Torben Wilson <torben@php.net> Netmill iTech|
|http://www.coastnet.com/~torben http://www.netmill.fi|
|Ph: 1 250 383-9735 torben@netmill.fi|
+----------------------------------------------------------------+