Surender Singh Lamba Surender Singh Lamba - 4 months ago 14x
Swift Question

FMDB check if empty method and move forward seperation

In FMDB the 'next' function (as-in if a!.next {}) does both checking if there is another row and also moving forward if there is another row, can we do these things separately, like only check if there is another row?

I have read the documentation but there seems no such direct method.

Rob Rob

The next method in FMDB is simply a wrapper around the sqlite3_step function. You may be used to the separation of "advance the recordset" and EOF-test that you see in other environments, but this is just how SQLite does it.

So, unfortunately, no SQLite doesn't really have separate functions for "is there another row" and "retrieve the next row". It's one function, sqlite3_step, which is called by FMDB's next, that serves both purposes. See the SQLite C interface API for a complete list of the SQLite functions (for which FMDB is merely a thin wrapper).