|
|
the SQLModule class encapsulates access to a mySQL database. It provides methods to access, update, and delete data from the database.
bool connectTo (QString host,QString dbaseName,QString userName,QString password) |
Connect to a mySQL database with a given username and password.
Parameters:
host | The hostname of the machine running the database server. |
dbaseName | The name of the database to connect to. |
userName | the user name to use to establish connection. |
password | the password to use for the connection. |
Returns: true if the connection succeeded, false otherwise.
bool nextRow () |
Fetch the next row of the result set, if there is one. This function can only be used after a SELECT query that returned a non-empty result set.
PRECONDITIONS: mode() == ModeQuery
Here is an example of a typical multiple-row query.
sqlmod.query("SELECT * from emp where salary > 500"); for (; !sqlmod.atEnd(); sqlmod.nextRow()) cout << sqlmod[0] << " " << sqlmod[1] << endl;
Returns: true if a new row was fetched, false otherwise.
int mode () |
Determine what mode the module is in currently.
Returns: Either of ModeUndefied, ModeQuery or ModeUpdate.
bool atEnd () |
Determine if the result set is at end position.
PRECONDITIONS: mode() == ModeQuery
Returns: true if there are no more rows in the result set, false otherwise.
bool isEmpty () |
Determine if the query returned an empty result set.
PRECONDITIONS: mode() == ModeQuery
Returns: true if the result set is empty, false otherwise.
int rowCount () |
Get the number of rows that were returned by the query.
PRECONDITIONS: mode() == ModeQuery
Returns: The number of rows returned by the SELECT query.
int fieldCount () |
Get the number of fields (columns) in the result set.
PRECONDITIONS: mode() == ModeQuery
Returns: The number of fields in the result set.
QString error () |
Get the error message recieved from the server in case of an SQL error.
Returns: A string containing the error message.
QString fields (int index) |
Get a specific field of the result set, by number.
PRECONDITIONS: mode() == ModeQuery ; index < fieldCount()
Returns: A string containing the value of the field. a NULL field generates an empty string.
QString operator[] (int index) |
Get a specific field of the result set, by number. Same as fields().
PRECONDITIONS: mode() == ModeQuery ; index < fieldCount()
Returns: A string containing the value of the field. a NULL field generates an empty string.
bool operator++ () |
Move to the next row in the result set. Same as nextRow().
PRECONDITIONS: mode() == ModeQuery
Returns: true if the module could move to the next row, or false if it is at the end of the set.