1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/sql/tqsqldriver.cpp:52 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>TQSqlDriver Class</title>
<style type="text/css"><!--
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
<a href="index.html">
<font color="#004faf">Home</font></a>
| <a href="classes.html">
<font color="#004faf">All Classes</font></a>
| <a href="mainclasses.html">
<font color="#004faf">Main Classes</font></a>
| <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
| <a href="groups.html">
<font color="#004faf">Grouped Classes</font></a>
| <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>TQSqlDriver Class Reference<br><small>[<a href="sql.html">sql module</a>]</small></h1>
<p>The TQSqlDriver class is an abstract base class for accessing
SQL databases.
<a href="#details">More...</a>
<p><tt>#include <<a href="tqsqldriver-h.html">tqsqldriver.h</a>></tt>
<p>Inherits <a href="tqobject.html">TQObject</a>.
<p><a href="tqsqldriver-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn>enum <a href="#DriverFeature-enum"><b>DriverFeature</b></a> { Transactions, QuerySize, BLOB, Unicode, PreparedQueries, NamedPlaceholders, PositionalPlaceholders }</li>
<li class=fn><a href="#TQSqlDriver"><b>TQSqlDriver</b></a> ( TQObject * parent = 0, const char * name = 0 )</li>
<li class=fn><a href="#~TQSqlDriver"><b>~TQSqlDriver</b></a> ()</li>
<li class=fn>bool <a href="#isOpen"><b>isOpen</b></a> () const</li>
<li class=fn>bool <a href="#isOpenError"><b>isOpenError</b></a> () const</li>
<li class=fn>virtual bool <a href="#beginTransaction"><b>beginTransaction</b></a> ()</li>
<li class=fn>virtual bool <a href="#commitTransaction"><b>commitTransaction</b></a> ()</li>
<li class=fn>virtual bool <a href="#rollbackTransaction"><b>rollbackTransaction</b></a> ()</li>
<li class=fn>virtual TQStringList <a href="#tables"><b>tables</b></a> ( const TQString & tableType ) const</li>
<li class=fn>virtual TQSqlIndex <a href="#primaryIndex"><b>primaryIndex</b></a> ( const TQString & tableName ) const</li>
<li class=fn>virtual TQSqlRecord <a href="#record"><b>record</b></a> ( const TQString & tableName ) const</li>
<li class=fn>virtual TQSqlRecord <a href="#record-2"><b>record</b></a> ( const TQSqlQuery & query ) const</li>
<li class=fn>virtual TQSqlRecordInfo <a href="#recordInfo"><b>recordInfo</b></a> ( const TQString & tablename ) const</li>
<li class=fn>virtual TQSqlRecordInfo <a href="#recordInfo-2"><b>recordInfo</b></a> ( const TQSqlQuery & query ) const</li>
<li class=fn>virtual TQString <a href="#nullText"><b>nullText</b></a> () const</li>
<li class=fn>virtual TQString <a href="#formatValue"><b>formatValue</b></a> ( const TQSqlField * field, bool trimStrings = FALSE ) const</li>
<li class=fn>TQSqlError <a href="#lastError"><b>lastError</b></a> () const</li>
<li class=fn>virtual bool <a href="#hasFeature"><b>hasFeature</b></a> ( DriverFeature f ) const = 0</li>
<li class=fn>virtual bool <a href="#open"><b>open</b></a> ( const TQString & db, const TQString & user = TQString::null, const TQString & password = TQString::null, const TQString & host = TQString::null, int port = -1 ) = 0</li>
<li class=fn>virtual void <a href="#close"><b>close</b></a> () = 0</li>
<li class=fn>virtual TQSqlQuery <a href="#createQuery"><b>createQuery</b></a> () const = 0</li>
<li class=fn>bool <a href="#open-2"><b>open</b></a> ( const TQString & db, const TQString & user, const TQString & password, const TQString & host, int port, const TQString & connOpts )</li>
</ul>
<h2>Protected Members</h2>
<ul>
<li class=fn>virtual void <a href="#setOpen"><b>setOpen</b></a> ( bool o )</li>
<li class=fn>virtual void <a href="#setOpenError"><b>setOpenError</b></a> ( bool e )</li>
<li class=fn>virtual void <a href="#setLastError"><b>setLastError</b></a> ( const TQSqlError & e )</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>
The TQSqlDriver class is an abstract base class for accessing
SQL databases.
<p>
<p> This class should not be used directly. Use <a href="tqsqldatabase.html">TQSqlDatabase</a> instead.
<p>See also <a href="database.html">Database Classes</a>.
<hr><h2>Member Type Documentation</h2>
<h3 class=fn><a name="DriverFeature-enum"></a>TQSqlDriver::DriverFeature</h3>
<p> This enum contains a list of features a driver may support. Use
<a href="#hasFeature">hasFeature</a>() to query whether a feature is supported or not.
<ul>
<li><tt>TQSqlDriver::Transactions</tt> - whether the driver supports SQL transactions
<li><tt>TQSqlDriver::QuerySize</tt> - 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
<a href="tqsqlquery.html#size">TQSqlQuery::size</a>() will return -1
<li><tt>TQSqlDriver::BLOB</tt> - whether the driver supports Binary Large Object fields
<li><tt>TQSqlDriver::Unicode</tt> - whether the driver supports Unicode strings if the
database server does
<li><tt>TQSqlDriver::PreparedQueries</tt> - whether the driver supports prepared query execution
<li><tt>TQSqlDriver::NamedPlaceholders</tt> - whether the driver supports usage of named placeholders
<li><tt>TQSqlDriver::PositionalPlaceholders</tt> - whether the driver supports usage of positional placeholders
</ul><p> More information about supported features can be found in the
<a href="sql-driver.html">TQt SQL driver</a> documentation.
<p> <p>See also <a href="#hasFeature">hasFeature</a>().
<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="TQSqlDriver"></a>TQSqlDriver::TQSqlDriver ( <a href="tqobject.html">TQObject</a> * parent = 0, const char * name = 0 )
</h3>
Default constructor. Creates a new driver with parent <em>parent</em>,
called <em>name</em>.
<p>
<h3 class=fn><a name="~TQSqlDriver"></a>TQSqlDriver::~TQSqlDriver ()
</h3>
Destroys the object and frees any allocated resources.
<h3 class=fn>bool <a name="beginTransaction"></a>TQSqlDriver::beginTransaction ()<tt> [virtual]</tt>
</h3>
Protected function which derived classes can reimplement to begin
a transaction. If successful, return TRUE, otherwise return FALSE.
The default implementation returns FALSE.
<p> <p>See also <a href="#commitTransaction">commitTransaction</a>() and <a href="#rollbackTransaction">rollbackTransaction</a>().
<h3 class=fn>void <a name="close"></a>TQSqlDriver::close ()<tt> [pure virtual]</tt>
</h3>
<p> Derived classes must reimplement this abstract virtual function in
order to close the database connection. Return TRUE on success,
FALSE on failure.
<p> <p>See also <a href="#setOpen">setOpen</a>().
<p>
<h3 class=fn>bool <a name="commitTransaction"></a>TQSqlDriver::commitTransaction ()<tt> [virtual]</tt>
</h3>
Protected function which derived classes can reimplement to commit
a transaction. If successful, return TRUE, otherwise return FALSE.
The default implementation returns FALSE.
<p> <p>See also <a href="#beginTransaction">beginTransaction</a>() and <a href="#rollbackTransaction">rollbackTransaction</a>().
<h3 class=fn><a href="tqsqlquery.html">TQSqlQuery</a> <a name="createQuery"></a>TQSqlDriver::createQuery () const<tt> [pure virtual]</tt>
</h3>
<p> Creates an empty SQL result on the database. Derived classes must
reimplement this function and return a <a href="tqsqlquery.html">TQSqlQuery</a> object
appropriate for their database to the caller.
<p>
<h3 class=fn><a href="tqstring.html">TQString</a> <a name="formatValue"></a>TQSqlDriver::formatValue ( const <a href="tqsqlfield.html">TQSqlField</a> * field, bool trimStrings = FALSE ) const<tt> [virtual]</tt>
</h3>
Returns a string representation of the <em>field</em> value for the
database. This is used, for example, when constructing INSERT and
UPDATE statements.
<p> The default implementation returns the value formatted as a string
according to the following rules:
<p> <ul>
<p> <li> If <em>field</em> is NULL, <a href="#nullText">nullText</a>() is returned.
<p> <li> If <em>field</em> 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 <em>trimStrings</em> is
TRUE (the default is FALSE), all trailing whitespace is trimmed
from the field.
<p> <li> If <em>field</em> 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.
<p> <li> If <em>field</em> is bytearray data, and the driver can edit binary
fields, the value is formatted as a hexadecimal string.
<p> <li> For any other field type toString() will be called on its value
and the result returned.
<p> </ul>
<p> <p>See also <a href="tqvariant.html#toString">TQVariant::toString</a>().
<p>
<h3 class=fn>bool <a name="hasFeature"></a>TQSqlDriver::hasFeature ( <a href="tqsqldriver.html#DriverFeature-enum">DriverFeature</a> f ) const<tt> [pure virtual]</tt>
</h3>
<p> Returns TRUE if the driver supports feature <em>f</em>; otherwise
returns FALSE.
<p> Note that some databases need to be <a href="#open">open</a>() before this can be
determined.
<p> <p>See also <a href="#DriverFeature-enum">DriverFeature</a>.
<h3 class=fn>bool <a name="isOpen"></a>TQSqlDriver::isOpen () const
</h3>
Returns TRUE if the database connection is open; otherwise returns
FALSE.
<h3 class=fn>bool <a name="isOpenError"></a>TQSqlDriver::isOpenError () const
</h3>
Returns TRUE if the there was an error opening the database
connection; otherwise returns FALSE.
<h3 class=fn><a href="tqsqlerror.html">TQSqlError</a> <a name="lastError"></a>TQSqlDriver::lastError () const
</h3>
Returns a <a href="tqsqlerror.html">TQSqlError</a> object which contains information about the
last error that occurred on the database.
<h3 class=fn><a href="tqstring.html">TQString</a> <a name="nullText"></a>TQSqlDriver::nullText () const<tt> [virtual]</tt>
</h3>
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".
<h3 class=fn>bool <a name="open"></a>TQSqlDriver::open ( const <a href="tqstring.html">TQString</a> & db, const <a href="tqstring.html">TQString</a> & user = TQString::null, const <a href="tqstring.html">TQString</a> & password = TQString::null, const <a href="tqstring.html">TQString</a> & host = TQString::null, int port = -1 )<tt> [pure virtual]</tt>
</h3>
<p> Derived classes must reimplement this abstract virtual function in
order to open a database connection on database <em>db</em>, using user
name <em>user</em>, password <em>password</em>, host <em>host</em> and port <em>port</em>.
<p> The function <em>must</em> return TRUE on success and FALSE on failure.
<p> <p>See also <a href="#setOpen">setOpen</a>().
<p>
<h3 class=fn>bool <a name="open-2"></a>TQSqlDriver::open ( const <a href="tqstring.html">TQString</a> & db, const <a href="tqstring.html">TQString</a> & user, const <a href="tqstring.html">TQString</a> & password, const <a href="tqstring.html">TQString</a> & host, int port, const <a href="tqstring.html">TQString</a> & connOpts )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Open a database connection on database <em>db</em>, using user name <em>user</em>, password <em>password</em>, host <em>host</em>, port <em>port</em> and
connection options <em>connOpts</em>.
<p> Returns TRUE on success and FALSE on failure.
<p> <p>See also <a href="#setOpen">setOpen</a>().
<h3 class=fn><a href="tqsqlindex.html">TQSqlIndex</a> <a name="primaryIndex"></a>TQSqlDriver::primaryIndex ( const <a href="tqstring.html">TQString</a> & tableName ) const<tt> [virtual]</tt>
</h3>
Returns the primary index for table <em>tableName</em>. Returns an empty
<a href="tqsqlindex.html">TQSqlIndex</a> if the table doesn't have a primary index. The default
implementation returns an empty index.
<h3 class=fn><a href="tqsqlrecord.html">TQSqlRecord</a> <a name="record"></a>TQSqlDriver::record ( const <a href="tqstring.html">TQString</a> & tableName ) const<tt> [virtual]</tt>
</h3>
Returns a <a href="tqsqlrecord.html">TQSqlRecord</a> populated with the names of the fields in
table <em>tableName</em>. If no such table exists, an empty record is
returned. The default implementation returns an empty record.
<h3 class=fn><a href="tqsqlrecord.html">TQSqlRecord</a> <a name="record-2"></a>TQSqlDriver::record ( const <a href="tqsqlquery.html">TQSqlQuery</a> & query ) const<tt> [virtual]</tt>
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Returns a <a href="tqsqlrecord.html">TQSqlRecord</a> populated with the names of the fields in the
SQL <em>query</em>. The default implementation returns an empty record.
<h3 class=fn><a href="tqsqlrecordinfo.html">TQSqlRecordInfo</a> <a name="recordInfo"></a>TQSqlDriver::recordInfo ( const <a href="tqstring.html">TQString</a> & tablename ) const<tt> [virtual]</tt>
</h3>
Returns a <a href="tqsqlrecordinfo.html">TQSqlRecordInfo</a> object with meta data about the table <em>tablename</em>.
<h3 class=fn><a href="tqsqlrecordinfo.html">TQSqlRecordInfo</a> <a name="recordInfo-2"></a>TQSqlDriver::recordInfo ( const <a href="tqsqlquery.html">TQSqlQuery</a> & query ) const<tt> [virtual]</tt>
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Returns a <a href="tqsqlrecordinfo.html">TQSqlRecordInfo</a> object with meta data for the <a href="tqsqlquery.html">TQSqlQuery</a>
<em>query</em>. Note that this overloaded function may return less
information than the <a href="#recordInfo">recordInfo</a>() function which takes the name of
a table as parameter.
<h3 class=fn>bool <a name="rollbackTransaction"></a>TQSqlDriver::rollbackTransaction ()<tt> [virtual]</tt>
</h3>
Protected function which derived classes can reimplement to
rollback a transaction. If successful, return TRUE, otherwise
return FALSE. The default implementation returns FALSE.
<p> <p>See also <a href="#beginTransaction">beginTransaction</a>() and <a href="#commitTransaction">commitTransaction</a>().
<h3 class=fn>void <a name="setLastError"></a>TQSqlDriver::setLastError ( const <a href="tqsqlerror.html">TQSqlError</a> & e )<tt> [virtual protected]</tt>
</h3>
Protected function which allows derived classes to set the value
of the last error, <em>e</em>, that occurred on the database.
<p> <p>See also <a href="#lastError">lastError</a>().
<h3 class=fn>void <a name="setOpen"></a>TQSqlDriver::setOpen ( bool o )<tt> [virtual protected]</tt>
</h3>
Protected function which sets the open state of the database to <em>o</em>. Derived classes can use this function to report the status of
<a href="#open">open</a>().
<p> <p>See also <a href="#open">open</a>() and <a href="#setOpenError">setOpenError</a>().
<h3 class=fn>void <a name="setOpenError"></a>TQSqlDriver::setOpenError ( bool e )<tt> [virtual protected]</tt>
</h3>
Protected function which sets the open error state of the database
to <em>e</em>. Derived classes can use this function to report the
status of <a href="#open">open</a>(). Note that if <em>e</em> is TRUE the open state of the
database is set to closed (i.e. <a href="#isOpen">isOpen</a>() returns FALSE).
<p> <p>See also <a href="#open">open</a>().
<h3 class=fn><a href="tqstringlist.html">TQStringList</a> <a name="tables"></a>TQSqlDriver::tables ( const <a href="tqstring.html">TQString</a> & tableType ) const<tt> [virtual]</tt>
</h3>
Returns a list of tables in the database. The default
implementation returns an empty list.
<p> The <em>tableType</em> 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.
<p> <p>See also <a href="tqsql.html#TableType-enum">TQSql::TableType</a>.
<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">TQt toolkit</a>.
Copyright © 1995-2007
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright © 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>TQt 3.3.8</div>
</table></div></address></body>
</html>
|