Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions

QSqlDriver Class Reference
[sql module]

The QSqlDriver class is an abstract base class for accessing SQL databases. More...

#include <qsqldriver.h>

Inherits QObject.

List of all member functions.

Public Members

Protected Members


Detailed Description

The QSqlDriver class is an abstract base class for accessing SQL databases.

This class should not be used directly. Use QSqlDatabase instead.

See also Database Classes.


Member Type Documentation

QSqlDriver::DriverFeature

This enum contains a list of features a driver may support. Use hasFeature() to query whether a feature is supported or not.

More information about supported features can be found in the Qt SQL driver documentation.

See also hasFeature().


Member Function Documentation

QSqlDriver::QSqlDriver ( QObject * parent = 0, const char * name = 0 )

Default constructor. Creates a new driver with parent parent, called name.

QSqlDriver::~QSqlDriver ()

Destroys the object and frees any allocated resources.

bool QSqlDriver::beginTransaction () [virtual]

Protected function which derived classes can reimplement to begin a transaction. If successful, return TRUE, otherwise return FALSE. The default implementation returns FALSE.

See also commitTransaction() and rollbackTransaction().

void QSqlDriver::close () [pure virtual]

Derived classes must reimplement this abstract virtual function in order to close the database connection. Return TRUE on success, FALSE on failure.

See also setOpen().

bool QSqlDriver::commitTransaction () [virtual]

Protected function which derived classes can reimplement to commit a transaction. If successful, return TRUE, otherwise return FALSE. The default implementation returns FALSE.

See also beginTransaction() and rollbackTransaction().

QSqlQuery QSqlDriver::createQuery () const [pure virtual]

Creates an empty SQL result on the database. Derived classes must reimplement this function and return a QSqlQuery object appropriate for their database to the caller.

QString QSqlDriver::formatValue ( const QSqlField * field, bool trimStrings = FALSE ) const [virtual]

Returns a string representation of the field value for the database. This is used, for example, when constructing INSERT and UPDATE statements.

The default implementation returns the value formatted as a string according to the following rules:

See also QVariant::toString().

bool QSqlDriver::hasFeature ( DriverFeature f ) const [pure virtual]

Returns TRUE if the driver supports feature f; otherwise returns FALSE.

Note that some databases need to be open() before this can be determined.

See also DriverFeature.

bool QSqlDriver::isOpen () const

Returns TRUE if the database connection is open; otherwise returns FALSE.

bool QSqlDriver::isOpenError () const

Returns TRUE if the there was an error opening the database connection; otherwise returns FALSE.

QSqlError QSqlDriver::lastError () const

Returns a QSqlError object which contains information about the last error that occurred on the database.

QString QSqlDriver::nullText () const [virtual]

Returns a string representation of the NULL value for the database. This is used, for example, when constructing INSERT and UPDATE statements. The default implementation returns the string "NULL".

bool QSqlDriver::open ( const QString & db, const QString & user = QString::null, const QString & password = QString::null, const QString & host = QString::null, int port = -1 ) [pure virtual]

Derived classes must reimplement this abstract virtual function in order to open a database connection on database db, using user name user, password password, host host and port port.

The function must return TRUE on success and FALSE on failure.

See also setOpen().

QSqlIndex QSqlDriver::primaryIndex ( const QString & tableName ) const [virtual]

Returns the primary index for table tableName. Returns an empty QSqlIndex if the table doesn't have a primary index. The default implementation returns an empty index.

QSqlRecord QSqlDriver::record ( const QString & tableName ) const [virtual]

Returns a QSqlRecord populated with the names of the fields in table tableName. If no such table exists, an empty record is returned. The default implementation returns an empty record.

QSqlRecord QSqlDriver::record ( const QSqlQuery & query ) const [virtual]

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Returns a QSqlRecord populated with the names of the fields in the SQL query. The default implementation returns an empty record.

QSqlRecordInfo QSqlDriver::recordInfo ( const QString & tablename ) const [virtual]

Returns a QSqlRecordInfo object with meta data about the table tablename.

QSqlRecordInfo QSqlDriver::recordInfo ( const QSqlQuery & query ) const [virtual]

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Returns a QSqlRecordInfo object with meta data for the QSqlQuery query. Note that this overloaded function may return less information than the recordInfo() function which takes the name of a table as parameter.

bool QSqlDriver::rollbackTransaction () [virtual]

Protected function which derived classes can reimplement to rollback a transaction. If successful, return TRUE, otherwise return FALSE. The default implementation returns FALSE.

See also beginTransaction() and commitTransaction().

void QSqlDriver::setLastError ( const QSqlError & e ) [virtual protected]

Protected function which allows derived classes to set the value of the last error, e, that occurred on the database.

See also lastError().

void QSqlDriver::setOpen ( bool o ) [virtual protected]

Protected function which sets the open state of the database to o. Derived classes can use this function to report the status of open().

See also open() and setOpenError().

void QSqlDriver::setOpenError ( bool e ) [virtual protected]

Protected function which sets the open error state of the database to e. Derived classes can use this function to report the status of open(). Note that if e is TRUE the open state of the database is set to closed (i.e. isOpen() returns FALSE).

See also open().

QStringList QSqlDriver::tables ( const QString & user ) const [virtual]

Returns a list of tables in the database. The default implementation returns an empty list.

Currently the user argument is unused.


This file is part of the Qt toolkit. Copyright © 1995-2003 Trolltech. All Rights Reserved.


Copyright © 2003 TrolltechTrademarks
Qt version 3.1.2