3
3
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
4
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
<!-- /fasttmp/mkdist-qt-4.5.2-1245473805/qt-x11-opensource-src-4.5.2/src/sql/kernel/qsqldriver.cpp -->
5
<!-- qsqldriver.cpp -->
7
<title>Qt 4.5: QSqlDriver Class Reference</title>
7
<title>Qt 4.6: QSqlDriver Class Reference</title>
8
8
<link href="classic.css" rel="stylesheet" type="text/css" />
11
<a name="//apple_ref/cpp/cl//QSqlDriver" />
11
12
<table border="0" cellpadding="0" cellspacing="0" width="100%">
13
<td align="left" valign="top" width="32"><a href="http://qtsoftware.com/products/qt"><img src="images/qt-logo.png" align="left" border="0" /></a></td>
14
<td width="1"> </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="namespaces.html"><font color="#004faf">All Namespaces</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="groups.html"><font color="#004faf">Grouped Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a> · <a href="functions.html"><font color="#004faf">Functions</font></a></td>
15
<td align="right" valign="top" width="230"></td></tr></table><h1 class="title">QSqlDriver Class Reference<br /><span class="small-subtitle">[<a href="qtsql.html">QtSql</a> module]</span>
14
<td align="left" valign="top" width="32"><a href="http://qt.nokia.com/"><img src="images/qt-logo.png" align="left" border="0" /></a></td>
15
<td width="1"> </td><td class="postheader" 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="functions.html"><font color="#004faf">All Functions</font></a> · <a href="overviews.html"><font color="#004faf">Overviews</font></a></td><td class="searchBar" align="right" valign="center"><form action="http://www.google.com/cse" id="cse-search-box"><div><input type="hidden" name="cx" value="000136343326384750312:dhbxnqlakyu" /><input type="hidden" name="ie" value="UTF-8" /><input type="text" name="q" size="31" /><input type="submit" name="sa" value="Search" /></div></form></td>
16
</tr></table><h1 class="title">QSqlDriver Class Reference<br /><span class="small-subtitle">[<a href="qtsql.html">QtSql</a> module]</span>
17
18
<p>The QSqlDriver class is an abstract base class for accessing specific SQL databases. <a href="#details">More...</a></p>
18
<pre> #include <QSqlDriver></pre><p>Inherits <a href="qobject.html">QObject</a>.</p>
19
<pre> #include <QSqlDriver></pre><p><b>This class is not part of the Qt GUI Framework Edition.</b></p>
20
<p>Inherits <a href="qobject.html">QObject</a>.</p>
20
22
<li><a href="qsqldriver-members.html">List of all members, including inherited members</a></li>
21
23
<li><a href="qsqldriver-qt3.html">Qt 3 support members</a></li>
23
26
<a name="public-types"></a>
26
<li><div class="fn"></div>enum <b><a href="qsqldriver.html#DriverFeature-enum">DriverFeature</a></b> { Transactions, QuerySize, BLOB, Unicode, ..., MultipleResultSets }</li>
27
<li><div class="fn"></div>enum <b><a href="qsqldriver.html#IdentifierType-enum">IdentifierType</a></b> { FieldName, TableName }</li>
28
<li><div class="fn"></div>enum <b><a href="qsqldriver.html#StatementType-enum">StatementType</a></b> { WhereStatement, SelectStatement, UpdateStatement, InsertStatement, DeleteStatement }</li>
28
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
29
<tr><td class="memItemLeft" align="right" valign="top">enum </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#DriverFeature-enum">DriverFeature</a></b> { Transactions, QuerySize, BLOB, Unicode, ..., MultipleResultSets }</td></tr>
30
<tr><td class="memItemLeft" align="right" valign="top">enum </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#IdentifierType-enum">IdentifierType</a></b> { FieldName, TableName }</td></tr>
31
<tr><td class="memItemLeft" align="right" valign="top">enum </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#StatementType-enum">StatementType</a></b> { WhereStatement, SelectStatement, UpdateStatement, InsertStatement, DeleteStatement }</td></tr>
30
34
<a name="public-functions"></a>
31
<h3>Public Functions</h3>
33
<li><div class="fn"></div><b><a href="qsqldriver.html#QSqlDriver">QSqlDriver</a></b> ( QObject * <i>parent</i> = 0 )</li>
34
<li><div class="fn"></div><b><a href="qsqldriver.html#dtor.QSqlDriver">~QSqlDriver</a></b> ()</li>
35
<li><div class="fn"></div>virtual bool <b><a href="qsqldriver.html#beginTransaction">beginTransaction</a></b> ()</li>
36
<li><div class="fn"></div>virtual void <b><a href="qsqldriver.html#close">close</a></b> () = 0</li>
37
<li><div class="fn"></div>virtual bool <b><a href="qsqldriver.html#commitTransaction">commitTransaction</a></b> ()</li>
38
<li><div class="fn"></div>virtual QSqlResult * <b><a href="qsqldriver.html#createResult">createResult</a></b> () const = 0</li>
39
<li><div class="fn"></div>virtual QString <b><a href="qsqldriver.html#escapeIdentifier">escapeIdentifier</a></b> ( const QString & <i>identifier</i>, IdentifierType <i>type</i> ) const</li>
40
<li><div class="fn"></div>virtual QString <b><a href="qsqldriver.html#formatValue">formatValue</a></b> ( const QSqlField & <i>field</i>, bool <i>trimStrings</i> = false ) const</li>
41
<li><div class="fn"></div>virtual QVariant <b><a href="qsqldriver.html#handle">handle</a></b> () const</li>
42
<li><div class="fn"></div>virtual bool <b><a href="qsqldriver.html#hasFeature">hasFeature</a></b> ( DriverFeature <i>feature</i> ) const = 0</li>
43
<li><div class="fn"></div>virtual bool <b><a href="qsqldriver.html#isOpen">isOpen</a></b> () const</li>
44
<li><div class="fn"></div>bool <b><a href="qsqldriver.html#isOpenError">isOpenError</a></b> () const</li>
45
<li><div class="fn"></div>QSqlError <b><a href="qsqldriver.html#lastError">lastError</a></b> () const</li>
46
<li><div class="fn"></div>virtual bool <b><a href="qsqldriver.html#open">open</a></b> ( const QString & <i>db</i>, const QString & <i>user</i> = QString(), const QString & <i>password</i> = QString(), const QString & <i>host</i> = QString(), int <i>port</i> = -1, const QString & <i>options</i> = QString() ) = 0</li>
47
<li><div class="fn"></div>virtual QSqlIndex <b><a href="qsqldriver.html#primaryIndex">primaryIndex</a></b> ( const QString & <i>tableName</i> ) const</li>
48
<li><div class="fn"></div>virtual QSqlRecord <b><a href="qsqldriver.html#record">record</a></b> ( const QString & <i>tableName</i> ) const</li>
49
<li><div class="fn"></div>virtual bool <b><a href="qsqldriver.html#rollbackTransaction">rollbackTransaction</a></b> ()</li>
50
<li><div class="fn"></div>virtual QString <b><a href="qsqldriver.html#sqlStatement">sqlStatement</a></b> ( StatementType <i>type</i>, const QString & <i>tableName</i>, const QSqlRecord & <i>rec</i>, bool <i>preparedStatement</i> ) const</li>
51
<li><div class="fn"></div>bool <b><a href="qsqldriver.html#subscribeToNotification">subscribeToNotification</a></b> ( const QString & <i>name</i> )</li>
52
<li><div class="fn"></div>QStringList <b><a href="qsqldriver.html#subscribedToNotifications">subscribedToNotifications</a></b> () const</li>
53
<li><div class="fn"></div>virtual QStringList <b><a href="qsqldriver.html#tables">tables</a></b> ( QSql::TableType <i>tableType</i> ) const</li>
54
<li><div class="fn"></div>bool <b><a href="qsqldriver.html#unsubscribeFromNotification">unsubscribeFromNotification</a></b> ( const QString & <i>name</i> )</li>
57
<li><div class="fn"></div>29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
35
<h2>Public Functions</h2>
36
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
37
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#QSqlDriver">QSqlDriver</a></b> ( QObject * <i>parent</i> = 0 )</td></tr>
38
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#dtor.QSqlDriver">~QSqlDriver</a></b> ()</td></tr>
39
<tr><td class="memItemLeft" align="right" valign="top">virtual bool </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#beginTransaction">beginTransaction</a></b> ()</td></tr>
40
<tr><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#close">close</a></b> () = 0</td></tr>
41
<tr><td class="memItemLeft" align="right" valign="top">virtual bool </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#commitTransaction">commitTransaction</a></b> ()</td></tr>
42
<tr><td class="memItemLeft" align="right" valign="top">virtual QSqlResult * </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#createResult">createResult</a></b> () const = 0</td></tr>
43
<tr><td class="memItemLeft" align="right" valign="top">virtual QString </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#escapeIdentifier">escapeIdentifier</a></b> ( const QString & <i>identifier</i>, IdentifierType <i>type</i> ) const</td></tr>
44
<tr><td class="memItemLeft" align="right" valign="top">virtual QString </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#formatValue">formatValue</a></b> ( const QSqlField & <i>field</i>, bool <i>trimStrings</i> = false ) const</td></tr>
45
<tr><td class="memItemLeft" align="right" valign="top">virtual QVariant </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#handle">handle</a></b> () const</td></tr>
46
<tr><td class="memItemLeft" align="right" valign="top">virtual bool </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#hasFeature">hasFeature</a></b> ( DriverFeature <i>feature</i> ) const = 0</td></tr>
47
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#isIdentifierEscaped">isIdentifierEscaped</a></b> ( const QString & <i>identifier</i>, IdentifierType <i>type</i> ) const</td></tr>
48
<tr><td class="memItemLeft" align="right" valign="top">virtual bool </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#isOpen">isOpen</a></b> () const</td></tr>
49
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#isOpenError">isOpenError</a></b> () const</td></tr>
50
<tr><td class="memItemLeft" align="right" valign="top">QSqlError </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#lastError">lastError</a></b> () const</td></tr>
51
<tr><td class="memItemLeft" align="right" valign="top">QSql::NumericalPrecisionPolicy </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#numericalPrecisionPolicy">numericalPrecisionPolicy</a></b> () const</td></tr>
52
<tr><td class="memItemLeft" align="right" valign="top">virtual bool </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#open">open</a></b> ( const QString & <i>db</i>, const QString & <i>user</i> = QString(), const QString & <i>password</i> = QString(), const QString & <i>host</i> = QString(), int <i>port</i> = -1, const QString & <i>options</i> = QString() ) = 0</td></tr>
53
<tr><td class="memItemLeft" align="right" valign="top">virtual QSqlIndex </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#primaryIndex">primaryIndex</a></b> ( const QString & <i>tableName</i> ) const</td></tr>
54
<tr><td class="memItemLeft" align="right" valign="top">virtual QSqlRecord </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#record">record</a></b> ( const QString & <i>tableName</i> ) const</td></tr>
55
<tr><td class="memItemLeft" align="right" valign="top">virtual bool </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#rollbackTransaction">rollbackTransaction</a></b> ()</td></tr>
56
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#setNumericalPrecisionPolicy">setNumericalPrecisionPolicy</a></b> ( QSql::NumericalPrecisionPolicy <i>precisionPolicy</i> )</td></tr>
57
<tr><td class="memItemLeft" align="right" valign="top">virtual QString </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#sqlStatement">sqlStatement</a></b> ( StatementType <i>type</i>, const QString & <i>tableName</i>, const QSqlRecord & <i>rec</i>, bool <i>preparedStatement</i> ) const</td></tr>
58
<tr><td class="memItemLeft" align="right" valign="top">QString </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#stripDelimiters">stripDelimiters</a></b> ( const QString & <i>identifier</i>, IdentifierType <i>type</i> ) const</td></tr>
59
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#subscribeToNotification">subscribeToNotification</a></b> ( const QString & <i>name</i> )</td></tr>
60
<tr><td class="memItemLeft" align="right" valign="top">QStringList </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#subscribedToNotifications">subscribedToNotifications</a></b> () const</td></tr>
61
<tr><td class="memItemLeft" align="right" valign="top">virtual QStringList </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#tables">tables</a></b> ( QSql::TableType <i>tableType</i> ) const</td></tr>
62
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#unsubscribeFromNotification">unsubscribeFromNotification</a></b> ( const QString & <i>name</i> )</td></tr>
65
<li><div bar="2" class="fn"></div>29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
59
68
<a name="signals"></a>
62
<li><div class="fn"></div>void <b><a href="qsqldriver.html#notification">notification</a></b> ( const QString & <i>name</i> )</li>
65
<li><div class="fn"></div>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
70
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
71
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#notification">notification</a></b> ( const QString & <i>name</i> )</td></tr>
74
<li><div bar="2" class="fn"></div>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
67
77
<a name="protected-functions"></a>
68
<h3>Protected Functions</h3>
70
<li><div class="fn"></div>virtual void <b><a href="qsqldriver.html#setLastError">setLastError</a></b> ( const QSqlError & <i>error</i> )</li>
71
<li><div class="fn"></div>virtual void <b><a href="qsqldriver.html#setOpen">setOpen</a></b> ( bool <i>open</i> )</li>
72
<li><div class="fn"></div>virtual void <b><a href="qsqldriver.html#setOpenError">setOpenError</a></b> ( bool <i>error</i> )</li>
75
<li><div class="fn"></div>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
78
<h2>Protected Functions</h2>
79
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
80
<tr><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#setLastError">setLastError</a></b> ( const QSqlError & <i>error</i> )</td></tr>
81
<tr><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#setOpen">setOpen</a></b> ( bool <i>open</i> )</td></tr>
82
<tr><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#setOpenError">setOpenError</a></b> ( bool <i>error</i> )</td></tr>
85
<li><div bar="2" class="fn"></div>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
77
88
<a name="protected-slots"></a>
78
<h3>Protected Slots</h3>
80
<li><div class="fn"></div>bool <b><a href="qsqldriver.html#subscribeToNotificationImplementation">subscribeToNotificationImplementation</a></b> ( const QString & <i>name</i> )</li>
81
<li><div class="fn"></div>QStringList <b><a href="qsqldriver.html#subscribedToNotificationsImplementation">subscribedToNotificationsImplementation</a></b> () const</li>
82
<li><div class="fn"></div>bool <b><a href="qsqldriver.html#unsubscribeFromNotificationImplementation">unsubscribeFromNotificationImplementation</a></b> ( const QString & <i>name</i> )</li>
89
<h2>Protected Slots</h2>
90
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
91
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#isIdentifierEscapedImplementation">isIdentifierEscapedImplementation</a></b> ( const QString & <i>identifier</i>, IdentifierType <i>type</i> ) const</td></tr>
92
<tr><td class="memItemLeft" align="right" valign="top">QString </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#stripDelimitersImplementation">stripDelimitersImplementation</a></b> ( const QString & <i>identifier</i>, IdentifierType <i>type</i> ) const</td></tr>
93
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#subscribeToNotificationImplementation">subscribeToNotificationImplementation</a></b> ( const QString & <i>name</i> )</td></tr>
94
<tr><td class="memItemLeft" align="right" valign="top">QStringList </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#subscribedToNotificationsImplementation">subscribedToNotificationsImplementation</a></b> () const</td></tr>
95
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qsqldriver.html#unsubscribeFromNotificationImplementation">unsubscribeFromNotificationImplementation</a></b> ( const QString & <i>name</i> )</td></tr>
84
97
<h3>Additional Inherited Members</h3>
86
99
<li><div class="fn"></div>1 property inherited from <a href="qobject.html#properties">QObject</a></li>
137
174
<p>See also <a href="qsqldriver.html#sqlStatement">sqlStatement</a>().</p>
139
176
<h2>Member Function Documentation</h2>
177
<a name="//apple_ref/cpp/instm/QSqlDriver/QSqlDriver" />
140
178
<h3 class="fn"><a name="QSqlDriver"></a>QSqlDriver::QSqlDriver ( <a href="qobject.html">QObject</a> * <i>parent</i> = 0 )</h3>
141
179
<p>Constructs a new driver with the given <i>parent</i>.</p>
180
<a name="//apple_ref/cpp/instm/QSqlDriver/~QSqlDriver" />
142
181
<h3 class="fn"><a name="dtor.QSqlDriver"></a>QSqlDriver::~QSqlDriver ()</h3>
143
182
<p>Destroys the object and frees any allocated resources.</p>
183
<a name="//apple_ref/cpp/instm/QSqlDriver/beginTransaction" />
144
184
<h3 class="fn"><a name="beginTransaction"></a>bool QSqlDriver::beginTransaction () <tt> [virtual]</tt></h3>
145
185
<p>This function is called to begin a transaction. If successful, return true, otherwise return false. The default implementation does nothing and returns false.</p>
146
186
<p>See also <a href="qsqldriver.html#commitTransaction">commitTransaction</a>() and <a href="qsqldriver.html#rollbackTransaction">rollbackTransaction</a>().</p>
187
<a name="//apple_ref/cpp/instm/QSqlDriver/close" />
147
188
<h3 class="fn"><a name="close"></a>void QSqlDriver::close () <tt> [pure virtual]</tt></h3>
148
189
<p>Derived classes must reimplement this pure virtual function in order to close the database connection. Return true on success, false on failure.</p>
149
190
<p>See also <a href="qsqldriver.html#open">open</a>() and <a href="qsqldriver.html#setOpen">setOpen</a>().</p>
191
<a name="//apple_ref/cpp/instm/QSqlDriver/commitTransaction" />
150
192
<h3 class="fn"><a name="commitTransaction"></a>bool QSqlDriver::commitTransaction () <tt> [virtual]</tt></h3>
151
193
<p>This function is called to commit a transaction. If successful, return true, otherwise return false. The default implementation does nothing and returns false.</p>
152
194
<p>See also <a href="qsqldriver.html#beginTransaction">beginTransaction</a>() and <a href="qsqldriver.html#rollbackTransaction">rollbackTransaction</a>().</p>
195
<a name="//apple_ref/cpp/instm/QSqlDriver/createResult" />
153
196
<h3 class="fn"><a name="createResult"></a><a href="qsqlresult.html">QSqlResult</a> * QSqlDriver::createResult () const <tt> [pure virtual]</tt></h3>
154
197
<p>Creates an empty SQL result on the database. Derived classes must reimplement this function and return a <a href="qsqlresult.html">QSqlResult</a> object appropriate for their database to the caller.</p>
198
<a name="//apple_ref/cpp/instm/QSqlDriver/escapeIdentifier" />
155
199
<h3 class="fn"><a name="escapeIdentifier"></a><a href="qstring.html">QString</a> QSqlDriver::escapeIdentifier ( const <a href="qstring.html">QString</a> & <i>identifier</i>, <a href="qsqldriver.html#IdentifierType-enum">IdentifierType</a> <i>type</i> ) const <tt> [virtual]</tt></h3>
156
200
<p>Returns the <i>identifier</i> escaped according to the database rules. <i>identifier</i> can either be a table name or field name, dependent on <i>type</i>.</p>
157
201
<p>The default implementation does nothing.</p>
202
<p>See also <a href="qsqldriver.html#isIdentifierEscaped">isIdentifierEscaped</a>().</p>
203
<a name="//apple_ref/cpp/instm/QSqlDriver/formatValue" />
158
204
<h3 class="fn"><a name="formatValue"></a><a href="qstring.html">QString</a> QSqlDriver::formatValue ( const <a href="qsqlfield.html">QSqlField</a> & <i>field</i>, bool <i>trimStrings</i> = false ) const <tt> [virtual]</tt></h3>
159
205
<p>Returns a string representation of the <i>field</i> value for the database. This is used, for example, when constructing INSERT and UPDATE statements.</p>
160
206
<p>The default implementation returns the value formatted as a string according to the following rules:</p>
192
239
if (handle != 0) ...
194
241
<p>See also <a href="qsqlresult.html#handle">QSqlResult::handle</a>().</p>
242
<a name="//apple_ref/cpp/instm/QSqlDriver/hasFeature" />
195
243
<h3 class="fn"><a name="hasFeature"></a>bool QSqlDriver::hasFeature ( <a href="qsqldriver.html#DriverFeature-enum">DriverFeature</a> <i>feature</i> ) const <tt> [pure virtual]</tt></h3>
196
244
<p>Returns true if the driver supports feature <i>feature</i>; otherwise returns false.</p>
197
245
<p>Note that some databases need to be <a href="qsqldriver.html#open">open</a>() before this can be determined.</p>
198
246
<p>See also <a href="qsqldriver.html#DriverFeature-enum">DriverFeature</a>.</p>
247
<a name="//apple_ref/cpp/instm/QSqlDriver/isIdentifierEscaped" />
248
<h3 class="fn"><a name="isIdentifierEscaped"></a>bool QSqlDriver::isIdentifierEscaped ( const <a href="qstring.html">QString</a> & <i>identifier</i>, <a href="qsqldriver.html#IdentifierType-enum">IdentifierType</a> <i>type</i> ) const</h3>
249
<p>Returns whether <i>identifier</i> is escaped according to the database rules. <i>identifier</i> can either be a table name or field name, dependent on <i>type</i>.</p>
250
<p><b>Warning:</b> Because of binary compatability constraints, this function is not virtual. If you want to provide your own implementation in your <a href="qsqldriver.html">QSqlDriver</a> subclass, reimplement the <a href="qsqldriver.html#isIdentifierEscapedImplementation">isIdentifierEscapedImplementation</a>() slot in your subclass instead. The isIdentifierEscapedFunction() will dynamically detect the slot and call it.</p>
251
<p>See also <a href="qsqldriver.html#stripDelimiters">stripDelimiters</a>() and <a href="qsqldriver.html#escapeIdentifier">escapeIdentifier</a>().</p>
252
<a name="//apple_ref/cpp/instm/QSqlDriver/isIdentifierEscapedImplementation" />
253
<h3 class="fn"><a name="isIdentifierEscapedImplementation"></a>bool QSqlDriver::isIdentifierEscapedImplementation ( const <a href="qstring.html">QString</a> & <i>identifier</i>, <a href="qsqldriver.html#IdentifierType-enum">IdentifierType</a> <i>type</i> ) const <tt> [protected slot]</tt></h3>
254
<p>This slot returns whether <i>identifier</i> is escaped according to the database rules. <i>identifier</i> can either be a table name or field name, dependent on <i>type</i>.</p>
255
<p>Because of binary compatability constraints, <a href="qsqldriver.html#isIdentifierEscaped">isIdentifierEscaped</a>() function (introduced in Qt 4.5) is not virtual. Instead, <a href="qsqldriver.html#isIdentifierEscaped">isIdentifierEscaped</a>() will dynamically detect and call <i>this</i> slot. The default implementation assumes the escape/delimiter character is a double quote. Reimplement this slot in your own <a href="qsqldriver.html">QSqlDriver</a> if your database engine uses a different delimiter character.</p>
256
<p>This function was introduced in Qt 4.6.</p>
257
<p>See also <a href="qsqldriver.html#isIdentifierEscaped">isIdentifierEscaped</a>().</p>
258
<a name="//apple_ref/cpp/instm/QSqlDriver/isOpen" />
199
259
<h3 class="fn"><a name="isOpen"></a>bool QSqlDriver::isOpen () const <tt> [virtual]</tt></h3>
200
260
<p>Returns true if the database connection is open; otherwise returns false.</p>
261
<a name="//apple_ref/cpp/instm/QSqlDriver/isOpenError" />
201
262
<h3 class="fn"><a name="isOpenError"></a>bool QSqlDriver::isOpenError () const</h3>
202
263
<p>Returns true if the there was an error opening the database connection; otherwise returns false.</p>
264
<a name="//apple_ref/cpp/instm/QSqlDriver/lastError" />
203
265
<h3 class="fn"><a name="lastError"></a><a href="qsqlerror.html">QSqlError</a> QSqlDriver::lastError () const</h3>
204
266
<p>Returns a <a href="qsqlerror.html">QSqlError</a> object which contains information about the last error that occurred on the database.</p>
205
267
<p>See also <a href="qsqldriver.html#setLastError">setLastError</a>().</p>
268
<a name="//apple_ref/cpp/instm/QSqlDriver/notification" />
206
269
<h3 class="fn"><a name="notification"></a>void QSqlDriver::notification ( const <a href="qstring.html">QString</a> & <i>name</i> ) <tt> [signal]</tt></h3>
207
270
<p>This signal is emitted when the database posts an event notification that the driver subscribes to. <i>name</i> identifies the event notification.</p>
208
271
<p>This function was introduced in Qt 4.4.</p>
209
272
<p>See also <a href="qsqldriver.html#subscribeToNotification">subscribeToNotification</a>().</p>
273
<a name="//apple_ref/cpp/instm/QSqlDriver/numericalPrecisionPolicy" />
274
<h3 class="fn"><a name="numericalPrecisionPolicy"></a><a href="qsql.html#NumericalPrecisionPolicy-enum">QSql::NumericalPrecisionPolicy</a> QSqlDriver::numericalPrecisionPolicy () const</h3>
275
<p>Returns the current default precision policy for the database connection.</p>
276
<p>This function was introduced in Qt 4.6.</p>
277
<p>See also <a href="qsql.html#NumericalPrecisionPolicy-enum">QSql::NumericalPrecisionPolicy</a>, <a href="qsqldriver.html#setNumericalPrecisionPolicy">setNumericalPrecisionPolicy</a>(), <a href="qsqlquery.html#numericalPrecisionPolicy">QSqlQuery::numericalPrecisionPolicy</a>(), and <a href="qsqlquery.html#setNumericalPrecisionPolicy">QSqlQuery::setNumericalPrecisionPolicy</a>().</p>
278
<a name="//apple_ref/cpp/instm/QSqlDriver/open" />
210
279
<h3 class="fn"><a name="open"></a>bool QSqlDriver::open ( const <a href="qstring.html">QString</a> & <i>db</i>, const <a href="qstring.html">QString</a> & <i>user</i> = QString(), const <a href="qstring.html">QString</a> & <i>password</i> = QString(), const <a href="qstring.html">QString</a> & <i>host</i> = QString(), int <i>port</i> = -1, const <a href="qstring.html">QString</a> & <i>options</i> = QString() ) <tt> [pure virtual]</tt></h3>
211
280
<p>Derived classes must reimplement this pure virtual function to open a database connection on database <i>db</i>, using user name <i>user</i>, password <i>password</i>, host <i>host</i>, port <i>port</i> and connection options <i>options</i>.</p>
212
281
<p>The function must return true on success and false on failure.</p>
213
282
<p>See also <a href="qsqldriver.html#setOpen">setOpen</a>().</p>
283
<a name="//apple_ref/cpp/instm/QSqlDriver/primaryIndex" />
214
284
<h3 class="fn"><a name="primaryIndex"></a><a href="qsqlindex.html">QSqlIndex</a> QSqlDriver::primaryIndex ( const <a href="qstring.html">QString</a> & <i>tableName</i> ) const <tt> [virtual]</tt></h3>
215
285
<p>Returns the primary index for table <i>tableName</i>. Returns an empty <a href="qsqlindex.html">QSqlIndex</a> if the table doesn't have a primary index. The default implementation returns an empty index.</p>
286
<a name="//apple_ref/cpp/instm/QSqlDriver/record" />
216
287
<h3 class="fn"><a name="record"></a><a href="qsqlrecord.html">QSqlRecord</a> QSqlDriver::record ( const <a href="qstring.html">QString</a> & <i>tableName</i> ) const <tt> [virtual]</tt></h3>
217
288
<p>Returns a <a href="qsqlrecord.html">QSqlRecord</a> populated with the names of the fields in table <i>tableName</i>. If no such table exists, an empty record is returned. The default implementation returns an empty record.</p>
289
<a name="//apple_ref/cpp/instm/QSqlDriver/rollbackTransaction" />
218
290
<h3 class="fn"><a name="rollbackTransaction"></a>bool QSqlDriver::rollbackTransaction () <tt> [virtual]</tt></h3>
219
291
<p>This function is called to rollback a transaction. If successful, return true, otherwise return false. The default implementation does nothing and returns false.</p>
220
292
<p>See also <a href="qsqldriver.html#beginTransaction">beginTransaction</a>() and <a href="qsqldriver.html#commitTransaction">commitTransaction</a>().</p>
293
<a name="//apple_ref/cpp/instm/QSqlDriver/setLastError" />
221
294
<h3 class="fn"><a name="setLastError"></a>void QSqlDriver::setLastError ( const <a href="qsqlerror.html">QSqlError</a> & <i>error</i> ) <tt> [virtual protected]</tt></h3>
222
295
<p>This function is used to set the value of the last error, <i>error</i>, that occurred on the database.</p>
223
296
<p>See also <a href="qsqldriver.html#lastError">lastError</a>().</p>
297
<a name="//apple_ref/cpp/instm/QSqlDriver/setNumericalPrecisionPolicy" />
298
<h3 class="fn"><a name="setNumericalPrecisionPolicy"></a>void QSqlDriver::setNumericalPrecisionPolicy ( <a href="qsql.html#NumericalPrecisionPolicy-enum">QSql::NumericalPrecisionPolicy</a> <i>precisionPolicy</i> )</h3>
299
<p>Sets the default numerical precision policy used by queries created by this driver to <i>precisionPolicy</i>.</p>
300
<p>Note: Setting the default precision policy to <i>precisionPolicy</i> doesn't affect any currently active queries.</p>
301
<p>This function was introduced in Qt 4.6.</p>
302
<p>See also <a href="qsql.html#NumericalPrecisionPolicy-enum">QSql::NumericalPrecisionPolicy</a>, <a href="qsqldriver.html#numericalPrecisionPolicy">numericalPrecisionPolicy</a>(), <a href="qsqlquery.html#setNumericalPrecisionPolicy">QSqlQuery::setNumericalPrecisionPolicy</a>(), and <a href="qsqlquery.html#numericalPrecisionPolicy">QSqlQuery::numericalPrecisionPolicy</a>().</p>
303
<a name="//apple_ref/cpp/instm/QSqlDriver/setOpen" />
224
304
<h3 class="fn"><a name="setOpen"></a>void QSqlDriver::setOpen ( bool <i>open</i> ) <tt> [virtual protected]</tt></h3>
225
305
<p>This function sets the open state of the database to <i>open</i>. Derived classes can use this function to report the status of <a href="qsqldriver.html#open">open</a>().</p>
226
306
<p>See also <a href="qsqldriver.html#open">open</a>() and <a href="qsqldriver.html#setOpenError">setOpenError</a>().</p>
307
<a name="//apple_ref/cpp/instm/QSqlDriver/setOpenError" />
227
308
<h3 class="fn"><a name="setOpenError"></a>void QSqlDriver::setOpenError ( bool <i>error</i> ) <tt> [virtual protected]</tt></h3>
228
309
<p>This function sets the open error state of the database to <i>error</i>. Derived classes can use this function to report the status of <a href="qsqldriver.html#open">open</a>(). Note that if <i>error</i> is true the open state of the database is set to closed (i.e., <a href="qsqldriver.html#isOpen">isOpen</a>() returns false).</p>
229
310
<p>See also <a href="qsqldriver.html#isOpenError">isOpenError</a>(), <a href="qsqldriver.html#open">open</a>(), and <a href="qsqldriver.html#setOpen">setOpen</a>().</p>
311
<a name="//apple_ref/cpp/instm/QSqlDriver/sqlStatement" />
230
312
<h3 class="fn"><a name="sqlStatement"></a><a href="qstring.html">QString</a> QSqlDriver::sqlStatement ( <a href="qsqldriver.html#StatementType-enum">StatementType</a> <i>type</i>, const <a href="qstring.html">QString</a> & <i>tableName</i>, const <a href="qsqlrecord.html">QSqlRecord</a> & <i>rec</i>, bool <i>preparedStatement</i> ) const <tt> [virtual]</tt></h3>
231
313
<p>Returns a SQL statement of type <i>type</i> for the table <i>tableName</i> with the values from <i>rec</i>. If <i>preparedStatement</i> is true, the string will contain placeholders instead of values.</p>
232
314
<p>This method can be used to manipulate tables without having to worry about database-dependent SQL dialects. For non-prepared statements, the values will be properly escaped.</p>
315
<a name="//apple_ref/cpp/instm/QSqlDriver/stripDelimiters" />
316
<h3 class="fn"><a name="stripDelimiters"></a><a href="qstring.html">QString</a> QSqlDriver::stripDelimiters ( const <a href="qstring.html">QString</a> & <i>identifier</i>, <a href="qsqldriver.html#IdentifierType-enum">IdentifierType</a> <i>type</i> ) const</h3>
317
<p>Returns the <i>identifier</i> with the leading and trailing delimiters removed, <i>identifier</i> can either be a table name or field name, dependent on <i>type</i>. If <i>identifier</i> does not have leading and trailing delimiter characters, <i>identifier</i> is returned without modification.</p>
318
<p><b>Warning:</b> Because of binary compatability constraints, this function is not virtual, If you want to provide your own implementation in your <a href="qsqldriver.html">QSqlDriver</a> subclass, reimplement the <a href="qsqldriver.html#stripDelimitersImplementation">stripDelimitersImplementation</a>() slot in your subclass instead. The stripDelimiters() function will dynamically detect the slot and call it.</p>
319
<p>This function was introduced in Qt 4.5.</p>
320
<p>See also <a href="qsqldriver.html#isIdentifierEscaped">isIdentifierEscaped</a>().</p>
321
<a name="//apple_ref/cpp/instm/QSqlDriver/stripDelimitersImplementation" />
322
<h3 class="fn"><a name="stripDelimitersImplementation"></a><a href="qstring.html">QString</a> QSqlDriver::stripDelimitersImplementation ( const <a href="qstring.html">QString</a> & <i>identifier</i>, <a href="qsqldriver.html#IdentifierType-enum">IdentifierType</a> <i>type</i> ) const <tt> [protected slot]</tt></h3>
323
<p>This slot returns <i>identifier</i> with the leading and trailing delimiters removed, <i>identifier</i> can either be a tablename or field name, dependent on <i>type</i>. If <i>identifier</i> does not have leading and trailing delimiter characters, <i>identifier</i> is returned without modification.</p>
324
<p>Because of binary compatability constraints, the <a href="qsqldriver.html#stripDelimiters">stripDelimiters</a>() function (introduced in Qt 4.5) is not virtual. Instead, <a href="qsqldriver.html#stripDelimiters">stripDelimiters</a>() will dynamically detect and call <i>this</i> slot. It generally unnecessary to reimplement this slot.</p>
325
<p>This function was introduced in Qt 4.6.</p>
326
<p>See also <a href="qsqldriver.html#stripDelimiters">stripDelimiters</a>().</p>
327
<a name="//apple_ref/cpp/instm/QSqlDriver/subscribeToNotification" />
233
328
<h3 class="fn"><a name="subscribeToNotification"></a>bool QSqlDriver::subscribeToNotification ( const <a href="qstring.html">QString</a> & <i>name</i> )</h3>
234
329
<p>This function is called to subscribe to event notifications from the database. <i>name</i> identifies the event notification.</p>
235
330
<p>If successful, return true, otherwise return false.</p>
246
342
<p>Reimplement this slot to provide your own <a href="qsqldriver.html">QSqlDriver</a> subclass with event notification support; because of binary compatibility constraints, the <a href="qsqldriver.html#subscribeToNotification">subscribeToNotification</a>() function (introduced in Qt 4.4) is not virtual. Instead, <a href="qsqldriver.html#subscribeToNotification">subscribeToNotification</a>() will dynamically detect and call <i>this</i> slot. The default implementation does nothing and returns false.</p>
247
343
<p>This function was introduced in Qt 4.4.</p>
248
344
<p>See also <a href="qsqldriver.html#subscribeToNotification">subscribeToNotification</a>().</p>
345
<a name="//apple_ref/cpp/instm/QSqlDriver/subscribedToNotifications" />
249
346
<h3 class="fn"><a name="subscribedToNotifications"></a><a href="qstringlist.html">QStringList</a> QSqlDriver::subscribedToNotifications () const</h3>
250
347
<p>Returns a list of the names of the event notifications that are currently subscribed to.</p>
251
348
<p><b>Warning:</b> Because of binary compatibility constraints, this function is not virtual. If you want to provide event notification support in your own <a href="qsqldriver.html">QSqlDriver</a> subclass, reimplement the <a href="qsqldriver.html#subscribedToNotificationsImplementation">subscribedToNotificationsImplementation</a>() slot in your subclass instead. The subscribedToNotifications() function will dynamically detect the slot and call it.</p>
252
349
<p>This function was introduced in Qt 4.4.</p>
253
350
<p>See also <a href="qsqldriver.html#subscribeToNotification">subscribeToNotification</a>() and <a href="qsqldriver.html#unsubscribeFromNotification">unsubscribeFromNotification</a>().</p>
351
<a name="//apple_ref/cpp/instm/QSqlDriver/subscribedToNotificationsImplementation" />
254
352
<h3 class="fn"><a name="subscribedToNotificationsImplementation"></a><a href="qstringlist.html">QStringList</a> QSqlDriver::subscribedToNotificationsImplementation () const <tt> [protected slot]</tt></h3>
255
353
<p>Returns a list of the names of the event notifications that are currently subscribed to.</p>
256
354
<p>Reimplement this slot to provide your own <a href="qsqldriver.html">QSqlDriver</a> subclass with event notification support; because of binary compatibility constraints, the <a href="qsqldriver.html#subscribedToNotifications">subscribedToNotifications</a>() function (introduced in Qt 4.4) is not virtual. Instead, <a href="qsqldriver.html#subscribedToNotifications">subscribedToNotifications</a>() will dynamically detect and call <i>this</i> slot. The default implementation simply returns an empty <a href="qstringlist.html">QStringList</a>.</p>
257
355
<p>This function was introduced in Qt 4.4.</p>
258
356
<p>See also <a href="qsqldriver.html#subscribedToNotifications">subscribedToNotifications</a>().</p>
357
<a name="//apple_ref/cpp/instm/QSqlDriver/tables" />
259
358
<h3 class="fn"><a name="tables"></a><a href="qstringlist.html">QStringList</a> QSqlDriver::tables ( <a href="qsql.html#TableType-enum">QSql::TableType</a> <i>tableType</i> ) const <tt> [virtual]</tt></h3>
260
359
<p>Returns a list of the names of the tables in the database. The default implementation returns an empty list.</p>
261
360
<p>The <i>tableType</i> argument describes what types of tables should be returned. Due to binary compatibility, the string contains the value of the enum QSql::TableTypes as text. An empty string should be treated as <a href="qsql.html#TableType-enum">QSql::Tables</a> for backward compatibility.</p>
361
<a name="//apple_ref/cpp/instm/QSqlDriver/unsubscribeFromNotification" />
262
362
<h3 class="fn"><a name="unsubscribeFromNotification"></a>bool QSqlDriver::unsubscribeFromNotification ( const <a href="qstring.html">QString</a> & <i>name</i> )</h3>
263
363
<p>This function is called to unsubscribe from event notifications from the database. <i>name</i> identifies the event notification.</p>
264
364
<p>If successful, return true, otherwise return false.</p>