TQSqlDriver(3qt)

NAME
TQSqlDriver - Abstract base class for accessing SQL databases

SYNOPSIS
#include <tqsqldriver.h>

Inherits TQObject.

  Public Members
enum DriverFeature { Transactions, QuerySize, BLOB, Unicode, PreparedQueries, NamedPlaceholders, PositionalPlaceholders }
TQSqlDriver ( TQObject * parent = 0, const char * name = 0 )
~TQSqlDriver ()
bool isOpen () const
bool isOpenError () const
virtual bool beginTransaction ()
virtual bool commitTransaction ()
virtual bool rollbackTransaction ()
virtual TQStringList tables ( const TQString & tableType ) const
virtual TQSqlIndex primaryIndex ( const TQString & tableName ) const
virtual TQSqlRecord record ( const TQString & tableName ) const
virtual TQSqlRecord record ( const TQSqlQuery & query ) const
virtual TQSqlRecordInfo recordInfo ( const TQString & tablename ) const
virtual TQSqlRecordInfo recordInfo ( const TQSqlQuery & query ) const
virtual TQString nullText () const
virtual TQString formatValue ( const TQSqlField * field, bool trimStrings = false ) const
TQSqlError lastError () const
virtual bool hasFeature ( DriverFeature f ) const = 0
virtual bool open ( const TQString & db, const TQString & user = TQString::null, const TQString & password = TQString::null, const TQString & host = TQString::null, int port = -1 ) = 0
virtual void close () = 0
virtual TQSqlQuery createQuery () const = 0
bool open ( const TQString & db, const TQString & user, const TQString & password, const TQString & host, int port, const TQString & connOpts )

  Protected Members
virtual void setOpen ( bool o )
virtual void setOpenError ( bool e )
virtual void setLastError ( const TQSqlError & e )

DESCRIPTION
The TQSqlDriver class is an abstract base class for accessing SQL databases.

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

See also Database Classes.

  Member Type Documentation

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

TQSqlDriver::Transactions - whether the driver supports SQL transactions

TQSqlDriver::QuerySize - whether the database is capable of reporting the size of a query. Note that some databases do not support returning the size (i.e. number of rows returned) of a query, in which case TQSqlQuery::size() will return -1

TQSqlDriver::BLOB - whether the driver supports Binary Large Object fields

TQSqlDriver::Unicode - whether the driver supports Unicode strings if the database server does

TQSqlDriver::PreparedQueries - whether the driver supports prepared query execution

TQSqlDriver::NamedPlaceholders - whether the driver supports usage of named placeholders

TQSqlDriver::PositionalPlaceholders - whether the driver supports usage of positional placeholders

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

See also hasFeature().

MEMBER FUNCTION DOCUMENTATION

TQSqlDriver::TQSqlDriver ( TQObject * parent = 0, const char * name = 0 )
Default constructor. Creates a new driver with parent parent, called name.

TQSqlDriver::~TQSqlDriver ()
Destroys the object and frees any allocated resources.

bool TQSqlDriver::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 TQSqlDriver::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 TQSqlDriver::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().

TQSqlQuery TQSqlDriver::createQuery () const [pure virtual]
Creates an empty SQL result on the database. Derived classes must reimplement this function and return a TQSqlQuery object appropriate for their database to the caller.

TQString TQSqlDriver::formatValue ( const TQSqlField * 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:

If field is NULL, nullText() is returned.

If field is character data, the value is returned enclosed in single quotation marks, which is appropriate for many SQL databases. Any embedded single-quote characters are escaped (replaced with two single-quote characters). If trimStrings is true (the default is false), all trailing whitespace is trimmed from the field.

If field is date/time data, the value is formatted in ISO format and enclosed in single quotation marks. If the date/time data is invalid, nullText() is returned.

If field is bytearray data, and the driver can edit binary fields, the value is formatted as a hexadecimal string.

For any other field type toString() will be called on its value and the result returned.

See also TQVariant::toString().

bool TQSqlDriver::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 TQSqlDriver::isOpen () const
Returns true if the database connection is open; otherwise returns false.

bool TQSqlDriver::isOpenError () const
Returns true if the there was an error opening the database connection; otherwise returns false.

TQSqlError TQSqlDriver::lastError () const
Returns a TQSqlError object which contains information about the last error that occurred on the database.

TQString TQSqlDriver::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 TQSqlDriver::open ( const TQString & db, const TQString & user = TQString::null, const TQString & password = TQString::null, const TQString & host = TQString::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().

bool TQSqlDriver::open ( const TQString & db, const TQString & user, const TQString & password, const TQString & host, int port, const TQString & connOpts )
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Open a database connection on database db, using user name user, password password, host host, port port and connection options connOpts.

Returns true on success and false on failure.

See also setOpen().

TQSqlIndex TQSqlDriver::primaryIndex ( const TQString & tableName ) const [virtual]
Returns the primary index for table tableName. Returns an empty TQSqlIndex if the table doesn't have a primary index. The default implementation returns an empty index.

TQSqlRecord TQSqlDriver::record ( const TQString & tableName ) const [virtual]
Returns a TQSqlRecord 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.

TQSqlRecord TQSqlDriver::record ( const TQSqlQuery & query ) const [virtual]
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

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

TQSqlRecordInfo TQSqlDriver::recordInfo ( const TQString & tablename ) const [virtual]
Returns a TQSqlRecordInfo object with meta data about the table tablename.

TQSqlRecordInfo TQSqlDriver::recordInfo ( const TQSqlQuery & query ) const [virtual]
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

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

bool TQSqlDriver::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 TQSqlDriver::setLastError ( const TQSqlError & 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 TQSqlDriver::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 TQSqlDriver::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().

TQStringList TQSqlDriver::tables ( const TQString & tableType ) const [virtual]
Returns a list of tables in the database. The default implementation returns an empty list.

The tableType argument describes what types of tables should be returned. Due to binary compatibility, the string contains the value of the enum TQSql::TableTypes as text. An empty string should be treated as TQSql::Tables for downward compatibility.

See also TQSql::TableType.

SEE ALSO
http://doc.trolltech.com/tqsqldriver.html http://www.trolltech.com/faq/tech.html

COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.

AUTHOR
Generated automatically from the source code.

BUGS
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you.

The definitive TQt documentation is provided in HTML format; it is located at $TQTDIR/doc/html and can be read using TQt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech.

If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (tqsqldriver.3qt) and the Qt version (3.3.8).