Is there a quick way to flush the select queue (if any) without causing a crash?

I tried doing this:

Code:
while(m_lastqueryresult.fetch_row());
But the issue there is if the last query was not a select query, or if there was no query at all, this will crash.

The issue is, if I try to run a query following a select query, if I did not select every single row, then try to select one last row, it will give a sync error.

So rather then have to call fetch_row each time to prevent a crash I just want to build it in my sql connector class so that it flushes it every time I do a query so that query wont crash.