class SQLModule

Transparent handling of SQL queries. More...

Definition#include <SQLModule.h>
InheritsQObject
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Public Members

Protected Members


Detailed Description

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:
hostThe hostname of the machine running the database server.
dbaseNameThe name of the database to connect to.
userNamethe user name to use to establish connection.
passwordthe 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 ()
[const]

Determine what mode the module is in currently.

Returns: Either of ModeUndefied, ModeQuery or ModeUpdate.

bool atEnd ()
[const]

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 ()
[const]

Determine if the query returned an empty result set.

PRECONDITIONS: mode() == ModeQuery

Returns: true if the result set is empty, false otherwise.

int rowCount ()
[const]

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 ()
[const]

Get the number of fields (columns) in the result set.

PRECONDITIONS: mode() == ModeQuery

Returns: The number of fields in the result set.

QString error ()
[const]

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)
[const]

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.