# database driver: no more rows

- Thread: https://externals.io/message/4939
- Original archive: https://news-web.php.net/php.internals/4939
- Started by Cesare D'Amico on 2003-10-23T12:58:43+00:00
- Messages: 4
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #4939 — Cesare D'Amico — 2003-10-23T12:58:43+00:00

URL: https://externals.io/message/4939#4939

Alle 00:18, giovedì 23 ottobre 2003, Lukas Smith ha scritto:
> run query that works
> run query that doesn't
>
> now when you fetch the rows of the first query you will usually
> determine if you hit the end if the result set by checking if you
> don't get an array returned
>
> if you don't get an array you check for an error and in several ext
> you will get the error created by the second query. This is also
> caused by the fact that the error checking simply returns the last
> error which cant be cleared appearently.

But can't you resolve this problem by checking if the query worked just 
after issuing it? I mean, do something like:

. run query 1
. check if q1 worked
. run query 2
. check if q2 worked
. if q1 worked -> fetch data

...and so on.

Perhaps I'm missing something, but I can't see a real issue here.

-- 
Cesare D'Amico - http://www.phpday.it
"E` un'emergenza!!! Dovrei fare questo-e-questaltro ma non 
posso perche' la mia testa e` piena di segatura e criceti!!!"
     -- un utente [ http://www.soft-land.org/storie/ ]

---

## #4940 — Lukas Smith — 2003-10-23T13:02:44+00:00

URL: https://externals.io/message/4939#4940 · In reply to: #4939

> From: Cesare D'Amico [mailto:cesare@ngi.it]
> Sent: Thursday, October 23, 2003 2:59 PM

> Alle 00:18, giovedì 23 ottobre 2003, Lukas Smith ha scritto:
> > […]
> 
> But can't you resolve this problem by checking if the query worked just
> after issuing it? I mean, do something like:
> 
> . run query 1
> . check if q1 worked
> . run query 2
> . check if q2 worked
> . if q1 worked -> fetch data
> 
> ...and so on.
> 
> Perhaps I'm missing something, but I can't see a real issue here.

Yeah, you are missing something :-/

mysql_error() will return you the last error over and over again.

So you find that q2 didnt work and you want to proceed then you will from
then on always get that failure from q2 until you produce a new error. This
is not the case in all ext but iirc atleast in mssql and sybase the problem
also seems to exist.

While I think about it: There would be one solution that wouldnt break BC:
adding a function that would clear the last error. Then you could manually
clear an error after you have read it.

The other alternative would be to remember the last error and check if that
error is the same every time you check and all such solutions are possible
but very hacky of course.

Regards,
Lukas

---

## #4943 — Dirkjan Ochtman — 2003-10-23T14:10:12+00:00

URL: https://externals.io/message/4939#4943 · In reply to: #4940

> While I think about it: There would be one solution that wouldn't break
BC:
> adding a function that would clear the last error. Then you could manually
> clear an error after you have read it.

I could see that mysql_reset_error() would be useful. + 1!

Regards,

Manuzhai

---

## #4945 — Andi Gutmans — 2003-10-23T15:45:08+00:00

URL: https://externals.io/message/4939#4945 · In reply to: #4939

At 03:02 PM 10/23/2003 +0200, Lukas Smith wrote:

>mysql_error() will return you the last error over and over again.

Shouldn't the mysql extension clear the last error on a successful query?

Andi
