Public Member Functions | |
Query_browser (Database *db, unsigned buf_size=DEF_BUFFER_SIZE) | |
Create new object. | |
virtual | ~Query_browser () |
Destroys object. | |
void | buffer_size (unsigned size) |
Change buffer size. | |
unsigned | buffer_size () const |
Get buffer size. | |
virtual void | first () |
Go to first row in result. | |
virtual void | last () |
Go to last row in result. | |
virtual bool | next () |
Go to next row in result. | |
virtual bool | prev () |
Go to previous row in result. | |
virtual bool | open (const wxString &sql) |
Open query - execute sql statement. | |
virtual bool | fetch (int rows, int flag=FM_FORWARD) |
Fetch data of some rows. | |
virtual bool | move (int rows, int flag=FM_FORWARD) |
Move cursor to different row without fetching data. | |
virtual bool | current (int new_curr) |
Set current row. | |
unsigned long long | abs_pos () const |
Absolute position in result. | |
unsigned long long | cursor_pos () const |
Database cursor position. | |
bool | is_last () const |
Is currently active row last in result. | |
unsigned long long | record_count () const |
Get number of rows in result. | |
bool | end_reached () const |
Is the end of result reached. | |
bool | go_to_record (unsigned long long row, unsigned buf_pos=0) |
Move to record by index. | |
Static Public Attributes | |
static const unsigned | DEF_BUFFER_SIZE = 50 |
Default buffer size. |
An object of this class keep a certain amount rows fetched to local buffer and alows working with entire result without worying about record fetching. NOTE: its not recomended to use fetch() and move() methods of this class.
wxPg::Query_browser::Query_browser | ( | Database * | db, | |
unsigned | buf_size = DEF_BUFFER_SIZE | |||
) | [explicit] |
Create new object.
db | - database connection. | |
buf_size | - buffer size, specifies a number of rows to be fetched to local buffer. |
virtual wxPg::Query_browser::~Query_browser | ( | ) | [inline, virtual] |
Destroys object.
unsigned long long wxPg::Query_browser::abs_pos | ( | ) | const [inline] |
Absolute position in result.
Don't mix this with current(), which returns position in current buffer.
unsigned wxPg::Query_browser::buffer_size | ( | ) | const [inline] |
Get buffer size.
void wxPg::Query_browser::buffer_size | ( | unsigned | size | ) | [inline] |
Change buffer size.
It is strongly recomended NOT to call this method when Query_browser is open.
size | - new buffer size. |
virtual bool wxPg::Query_browser::current | ( | int | idx | ) | [virtual] |
Set current row.
idx | - index of row to become current. |
Reimplemented from wxPg::Result_data.
unsigned long long wxPg::Query_browser::cursor_pos | ( | ) | const [inline] |
Database cursor position.
This function returns position of cursor, used for reading data from result.
bool wxPg::Query_browser::end_reached | ( | ) | const [inline] |
Is the end of result reached.
This method indicates, whether the end of result was reached at any time. The exact number of records in result is known only after the end of result is reached.
virtual bool wxPg::Query_browser::fetch | ( | int | rows, | |
int | flag = FM_FORWARD | |||
) | [virtual] |
Fetch data of some rows.
You need to call this method to obtain any data from query.
rows | - number of rows to be fetched. Ignored for some flags. | |
flag | sould be one of fetch and move actions. |
Reimplemented from wxPg::Query.
virtual void wxPg::Query_browser::first | ( | ) | [virtual] |
Go to first row in result.
bool wxPg::Query_browser::go_to_record | ( | unsigned long long | row, | |
unsigned | buf_pos = 0 | |||
) |
Move to record by index.
If requested record is in currently fetched buffer, only buffer position is changed. Otherwise a buffer with requested record is fetch, with attempt to fetch, that the requested record would be in buf_pos position in buffer.
In case of error returns back to the same record.
row | - a 0-based number of row in result. | |
buf_pos | - when fetch occurs, preferred buffer position. |
bool wxPg::Query_browser::is_last | ( | ) | const [inline] |
Is currently active row last in result.
This method returns false until the end of result is reached and the number of rows in result is known.
virtual void wxPg::Query_browser::last | ( | ) | [virtual] |
Go to last row in result.
virtual bool wxPg::Query_browser::move | ( | int | rows, | |
int | flag = FM_FORWARD | |||
) | [virtual] |
Move cursor to different row without fetching data.
rows | specifiels number of rows to move. Ignored for some flags. | |
flag | sould be one of fetch and move actions. Not all are accepted. |
Reimplemented from wxPg::Query.
virtual bool wxPg::Query_browser::next | ( | ) | [virtual] |
Go to next row in result.
virtual bool wxPg::Query_browser::open | ( | const wxString & | sql | ) | [virtual] |
Open query - execute sql statement.
Call last_err() for error message. Call fetch() to get all or part of returned result.
sql | specifies an SQL statement. |
Reimplemented from wxPg::Query.
virtual bool wxPg::Query_browser::prev | ( | ) | [virtual] |
Go to previous row in result.
unsigned long long wxPg::Query_browser::record_count | ( | ) | const [inline] |
Get number of rows in result.
The exact number of rows in result is unknown until the end of result is reached.
const unsigned wxPg::Query_browser::DEF_BUFFER_SIZE = 50 [static] |
Default buffer size.
Such amount of rows is fetched by default from query.