Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid seek position #4

Closed
anoxic opened this issue Oct 30, 2014 · 2 comments
Closed

Invalid seek position #4

anoxic opened this issue Oct 30, 2014 · 2 comments

Comments

@anoxic
Copy link
Contributor

anoxic commented Oct 30, 2014

Hello, I am getting the following error when trying to use $dabble->first() on an empty query.

invalid seek position (0)

And the trace

#0 [..]vendor/dabble/dabble/src/Dabble/Result.php(342): Dabble\Result->seek(0)
#1 [..]vendor/dabble/dabble/src/Dabble/Result.php(237): Dabble\Result->rewind(0)
#2 [..]/Transaction.php(311): Dabble\Result->first()

It's simple enough to get around by getting the count first, but I think another response may be more appropriate than an exception within dabbles' calls. I would lean towards returning false, but there are certainly other options.

@nramenta
Copy link
Owner

nramenta commented Nov 1, 2014

This change was introduced by 2a3dd78. I've made some changes to remedy this situation:

Result::seek strictly returns true or false, without throwing any exceptions. Furthermore, to closely follow mysqli, calls to the Result::fetch method -- indirectly through Result::first and Result::last -- return null (instead of false as you proposed) if you try to fetch from an empty result set.

@anoxic
Copy link
Contributor Author

anoxic commented Apr 27, 2015

I just noticed this wasn't closed yet. Thank you, this works well!

@anoxic anoxic closed this as completed Apr 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants