1QSqlDriver(3qt)                                                QSqlDriver(3qt)
2
3
4

NAME

6       QSqlDriver - Abstract base class for accessing SQL databases
7

SYNOPSIS

9       #include <qsqldriver.h>
10
11       Inherits QObject.
12
13   Public Members
14       enum DriverFeature { Transactions, QuerySize, BLOB, Unicode,
15           PreparedQueries, NamedPlaceholders, PositionalPlaceholders }
16       QSqlDriver ( QObject * parent = 0, const char * name = 0 )
17       ~QSqlDriver ()
18       bool isOpen () const
19       bool isOpenError () const
20       virtual bool beginTransaction ()
21       virtual bool commitTransaction ()
22       virtual bool rollbackTransaction ()
23       virtual QStringList tables ( const QString & tableType ) const
24       virtual QSqlIndex primaryIndex ( const QString & tableName ) const
25       virtual QSqlRecord record ( const QString & tableName ) const
26       virtual QSqlRecord record ( const QSqlQuery & query ) const
27       virtual QSqlRecordInfo recordInfo ( const QString & tablename ) const
28       virtual QSqlRecordInfo recordInfo ( const QSqlQuery & query ) const
29       virtual QString nullText () const
30       virtual QString formatValue ( const QSqlField * field, bool trimStrings
31           = FALSE ) const
32       QSqlError lastError () const
33       virtual bool hasFeature ( DriverFeature f ) const = 0
34       virtual bool open ( const QString & db, const QString & user =
35           QString::null, const QString & password = QString::null, const
36           QString & host = QString::null, int port = -1 ) = 0
37       virtual void close () = 0
38       virtual QSqlQuery createQuery () const = 0
39       bool open ( const QString & db, const QString & user, const QString &
40           password, const QString & host, int port, const QString & connOpts
41           )
42
43   Protected Members
44       virtual void setOpen ( bool o )
45       virtual void setOpenError ( bool e )
46       virtual void setLastError ( const QSqlError & e )
47

DESCRIPTION

49       The QSqlDriver class is an abstract base class for accessing SQL
50       databases.
51
52       This class should not be used directly. Use QSqlDatabase instead.
53
54       See also Database Classes.
55
56   Member Type Documentation

QSqlDriver::DriverFeature

58       This enum contains a list of features a driver may support. Use
59       hasFeature() to query whether a feature is supported or not.
60
61       QSqlDriver::Transactions - whether the driver supports SQL transactions
62
63       QSqlDriver::QuerySize - whether the database is capable of reporting
64       the size of a query. Note that some databases do not support returning
65       the size (i.e. number of rows returned) of a query, in which case
66       QSqlQuery::size() will return -1
67
68       QSqlDriver::BLOB - whether the driver supports Binary Large Object
69       fields
70
71       QSqlDriver::Unicode - whether the driver supports Unicode strings if
72       the database server does
73
74       QSqlDriver::PreparedQueries - whether the driver supports prepared
75       query execution
76
77       QSqlDriver::NamedPlaceholders - whether the driver supports usage of
78       named placeholders
79
80       QSqlDriver::PositionalPlaceholders - whether the driver supports usage
81       of positional placeholders
82
83       More information about supported features can be found in the Qt SQL
84       driver documentation.
85
86       See also hasFeature().
87

MEMBER FUNCTION DOCUMENTATION

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

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

QSqlDriver::~QSqlDriver ()

94       Destroys the object and frees any allocated resources.
95

bool QSqlDriver::beginTransaction () [virtual]

97       Protected function which derived classes can reimplement to begin a
98       transaction. If successful, return TRUE, otherwise return FALSE. The
99       default implementation returns FALSE.
100
101       See also commitTransaction() and rollbackTransaction().
102

void QSqlDriver::close () [pure virtual]

104       Derived classes must reimplement this abstract virtual function in
105       order to close the database connection. Return TRUE on success, FALSE
106       on failure.
107
108       See also setOpen().
109

bool QSqlDriver::commitTransaction () [virtual]

111       Protected function which derived classes can reimplement to commit a
112       transaction. If successful, return TRUE, otherwise return FALSE. The
113       default implementation returns FALSE.
114
115       See also beginTransaction() and rollbackTransaction().
116

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

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

QString QSqlDriver::formatValue ( const QSqlField * field, bool trimStrings =

123       FALSE ) const [virtual]
124       Returns a string representation of the field value for the database.
125       This is used, for example, when constructing INSERT and UPDATE
126       statements.
127
128       The default implementation returns the value formatted as a string
129       according to the following rules:
130
131       If field is NULL, nullText() is returned.
132
133       If field is character data, the value is returned enclosed in single
134       quotation marks, which is appropriate for many SQL databases. Any
135       embedded single-quote characters are escaped (replaced with two single-
136       quote characters). If trimStrings is TRUE (the default is FALSE), all
137       trailing whitespace is trimmed from the field.
138
139       If field is date/time data, the value is formatted in ISO format and
140       enclosed in single quotation marks. If the date/time data is invalid,
141       nullText() is returned.
142
143       If field is bytearray data, and the driver can edit binary fields, the
144       value is formatted as a hexadecimal string.
145
146       For any other field type toString() will be called on its value and the
147       result returned.
148
149       See also QVariant::toString().
150

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

152       Returns TRUE if the driver supports feature f; otherwise returns FALSE.
153
154       Note that some databases need to be open() before this can be
155       determined.
156
157       See also DriverFeature.
158

bool QSqlDriver::isOpen () const

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

bool QSqlDriver::isOpenError () const

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

QSqlError QSqlDriver::lastError () const

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

QString QSqlDriver::nullText () const [virtual]

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

bool QSqlDriver::open ( const QString & db, const QString & user =

177       QString::null, const QString & password = QString::null, const QString
178       & host = QString::null, int port = -1 ) [pure virtual]
179       Derived classes must reimplement this abstract virtual function in
180       order to open a database connection on database db, using user name
181       user, password password, host host and port port.
182
183       The function must return TRUE on success and FALSE on failure.
184
185       See also setOpen().
186

bool QSqlDriver::open ( const QString & db, const QString & user, const

188       QString & password, const QString & host, int port, const QString &
189       connOpts )
190       This is an overloaded member function, provided for convenience. It
191       behaves essentially like the above function.
192
193       Open a database connection on database db, using user name user,
194       password password, host host, port port and connection options
195       connOpts.
196
197       Returns TRUE on success and FALSE on failure.
198
199       See also setOpen().
200

QSqlIndex QSqlDriver::primaryIndex ( const QString & tableName ) const

202       [virtual]
203       Returns the primary index for table tableName. Returns an empty
204       QSqlIndex if the table doesn't have a primary index. The default
205       implementation returns an empty index.
206

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

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

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

213       This is an overloaded member function, provided for convenience. It
214       behaves essentially like the above function.
215
216       Returns a QSqlRecord populated with the names of the fields in the SQL
217       query. The default implementation returns an empty record.
218

QSqlRecordInfo QSqlDriver::recordInfo ( const QString & tablename ) const

220       [virtual]
221       Returns a QSqlRecordInfo object with meta data about the table
222       tablename.
223

QSqlRecordInfo QSqlDriver::recordInfo ( const QSqlQuery & query ) const

225       [virtual]
226       This is an overloaded member function, provided for convenience. It
227       behaves essentially like the above function.
228
229       Returns a QSqlRecordInfo object with meta data for the QSqlQuery query.
230       Note that this overloaded function may return less information than the
231       recordInfo() function which takes the name of a table as parameter.
232

bool QSqlDriver::rollbackTransaction () [virtual]

234       Protected function which derived classes can reimplement to rollback a
235       transaction. If successful, return TRUE, otherwise return FALSE. The
236       default implementation returns FALSE.
237
238       See also beginTransaction() and commitTransaction().
239

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

241       Protected function which allows derived classes to set the value of the
242       last error, e, that occurred on the database.
243
244       See also lastError().
245

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

247       Protected function which sets the open state of the database to o.
248       Derived classes can use this function to report the status of open().
249
250       See also open() and setOpenError().
251

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

253       Protected function which sets the open error state of the database to
254       e. Derived classes can use this function to report the status of
255       open(). Note that if e is TRUE the open state of the database is set to
256       closed (i.e. isOpen() returns FALSE).
257
258       See also open().
259

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

261       Returns a list of tables in the database. The default implementation
262       returns an empty list.
263
264       The tableType argument describes what types of tables should be
265       returned. Due to binary compatibility, the string contains the value of
266       the enum QSql::TableTypes as text. An empty string should be treated as
267       QSql::Tables for downward compatibility.
268
269       See also QSql::TableType.
270
271

SEE ALSO

273       http://doc.trolltech.com/qsqldriver.html
274       http://www.trolltech.com/faq/tech.html
275
277       Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
278       license file included in the distribution for a complete license
279       statement.
280

AUTHOR

282       Generated automatically from the source code.
283

BUGS

285       If you find a bug in Qt, please report it as described in
286       http://doc.trolltech.com/bughowto.html.  Good bug reports help us to
287       help you. Thank you.
288
289       The definitive Qt documentation is provided in HTML format; it is
290       located at $QTDIR/doc/html and can be read using Qt Assistant or with a
291       web browser. This man page is provided as a convenience for those users
292       who prefer man pages, although this format is not officially supported
293       by Trolltech.
294
295       If you find errors in this manual page, please report them to qt-
296       bugs@trolltech.com.  Please include the name of the manual page
297       (qsqldriver.3qt) and the Qt version (3.3.8).
298
299
300
301Trolltech AS                    2 February 2007                QSqlDriver(3qt)
Impressum