1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/sql/qsqlrecord.cpp:151 -->
|
---|
3 | <html>
|
---|
4 | <head>
|
---|
5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
6 | <title>QSqlRecord Class</title>
|
---|
7 | <style type="text/css"><!--
|
---|
8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
9 | a:link { color: #004faf; text-decoration: none }
|
---|
10 | a:visited { color: #672967; text-decoration: none }
|
---|
11 | body { background: #ffffff; color: black; }
|
---|
12 | --></style>
|
---|
13 | </head>
|
---|
14 | <body>
|
---|
15 |
|
---|
16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
17 | <tr bgcolor="#E5E5E5">
|
---|
18 | <td valign=center>
|
---|
19 | <a href="index.html">
|
---|
20 | <font color="#004faf">Home</font></a>
|
---|
21 | | <a href="classes.html">
|
---|
22 | <font color="#004faf">All Classes</font></a>
|
---|
23 | | <a href="mainclasses.html">
|
---|
24 | <font color="#004faf">Main Classes</font></a>
|
---|
25 | | <a href="annotated.html">
|
---|
26 | <font color="#004faf">Annotated</font></a>
|
---|
27 | | <a href="groups.html">
|
---|
28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
29 | | <a href="functions.html">
|
---|
30 | <font color="#004faf">Functions</font></a>
|
---|
31 | </td>
|
---|
32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QSqlRecord Class Reference<br><small>[<a href="sql.html">sql module</a>]</small></h1>
|
---|
33 |
|
---|
34 | <p>The QSqlRecord class encapsulates a database record, i.e. a
|
---|
35 | set of database fields.
|
---|
36 | <a href="#details">More...</a>
|
---|
37 | <p><tt>#include <<a href="qsqlrecord-h.html">qsqlrecord.h</a>></tt>
|
---|
38 | <p>Inherited by <a href="qsqlcursor.html">QSqlCursor</a> and <a href="qsqlindex.html">QSqlIndex</a>.
|
---|
39 | <p><a href="qsqlrecord-members.html">List of all member functions.</a>
|
---|
40 | <h2>Public Members</h2>
|
---|
41 | <ul>
|
---|
42 | <li class=fn><a href="#QSqlRecord"><b>QSqlRecord</b></a> ()</li>
|
---|
43 | <li class=fn><a href="#QSqlRecord-2"><b>QSqlRecord</b></a> ( const QSqlRecord & other )</li>
|
---|
44 | <li class=fn>QSqlRecord & <a href="#operator-eq"><b>operator=</b></a> ( const QSqlRecord & other )</li>
|
---|
45 | <li class=fn>virtual <a href="#~QSqlRecord"><b>~QSqlRecord</b></a> ()</li>
|
---|
46 | <li class=fn>virtual QVariant <a href="#value"><b>value</b></a> ( int i ) const</li>
|
---|
47 | <li class=fn>virtual QVariant <a href="#value-2"><b>value</b></a> ( const QString & name ) const</li>
|
---|
48 | <li class=fn>virtual void <a href="#setValue"><b>setValue</b></a> ( int i, const QVariant & val )</li>
|
---|
49 | <li class=fn>virtual void <a href="#setValue-2"><b>setValue</b></a> ( const QString & name, const QVariant & val )</li>
|
---|
50 | <li class=fn>bool <a href="#isGenerated-2"><b>isGenerated</b></a> ( int i ) const</li>
|
---|
51 | <li class=fn>bool <a href="#isGenerated"><b>isGenerated</b></a> ( const QString & name ) const</li>
|
---|
52 | <li class=fn>virtual void <a href="#setGenerated"><b>setGenerated</b></a> ( const QString & name, bool generated )</li>
|
---|
53 | <li class=fn>virtual void <a href="#setGenerated-2"><b>setGenerated</b></a> ( int i, bool generated )</li>
|
---|
54 | <li class=fn>virtual void <a href="#setNull"><b>setNull</b></a> ( int i )</li>
|
---|
55 | <li class=fn>virtual void <a href="#setNull-2"><b>setNull</b></a> ( const QString & name )</li>
|
---|
56 | <li class=fn>bool <a href="#isNull-4"><b>isNull</b></a> ( int i ) const</li>
|
---|
57 | <li class=fn>bool <a href="#isNull"><b>isNull</b></a> ( const QString & name ) const</li>
|
---|
58 | <li class=fn>int <a href="#position"><b>position</b></a> ( const QString & name ) const</li>
|
---|
59 | <li class=fn>QString <a href="#fieldName"><b>fieldName</b></a> ( int i ) const</li>
|
---|
60 | <li class=fn>QSqlField * <a href="#field"><b>field</b></a> ( int i )</li>
|
---|
61 | <li class=fn>QSqlField * <a href="#field-2"><b>field</b></a> ( const QString & name )</li>
|
---|
62 | <li class=fn>const QSqlField * <a href="#field-3"><b>field</b></a> ( int i ) const</li>
|
---|
63 | <li class=fn>const QSqlField * <a href="#field-4"><b>field</b></a> ( const QString & name ) const</li>
|
---|
64 | <li class=fn>virtual void <a href="#append"><b>append</b></a> ( const QSqlField & field )</li>
|
---|
65 | <li class=fn>virtual void <a href="#insert"><b>insert</b></a> ( int pos, const QSqlField & field )</li>
|
---|
66 | <li class=fn>virtual void <a href="#remove"><b>remove</b></a> ( int pos )</li>
|
---|
67 | <li class=fn>bool <a href="#isEmpty"><b>isEmpty</b></a> () const</li>
|
---|
68 | <li class=fn>bool <a href="#contains"><b>contains</b></a> ( const QString & name ) const</li>
|
---|
69 | <li class=fn>virtual void <a href="#clear"><b>clear</b></a> ()</li>
|
---|
70 | <li class=fn>virtual void <a href="#clearValues"><b>clearValues</b></a> ( bool nullify = FALSE )</li>
|
---|
71 | <li class=fn>uint <a href="#count"><b>count</b></a> () const</li>
|
---|
72 | <li class=fn>virtual QString <a href="#toString"><b>toString</b></a> ( const QString & prefix = QString::null, const QString & sep = "," ) const</li>
|
---|
73 | <li class=fn>virtual QStringList <a href="#toStringList"><b>toStringList</b></a> ( const QString & prefix = QString::null ) const</li>
|
---|
74 | </ul>
|
---|
75 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
76 |
|
---|
77 |
|
---|
78 | The QSqlRecord class encapsulates a database record, i.e. a
|
---|
79 | set of database fields.
|
---|
80 | <p>
|
---|
81 |
|
---|
82 | <p> The QSqlRecord class encapsulates the functionality and
|
---|
83 | characteristics of a database record (usually a table or view within
|
---|
84 | the database). QSqlRecords support adding and removing fields as
|
---|
85 | well as setting and retrieving field values.
|
---|
86 | <p> QSqlRecord is <a href="shclass.html#implicitly-shared">implicitly shared</a>. This means you can make copies of
|
---|
87 | the record in time O(1). If multiple QSqlRecord instances share
|
---|
88 | the same data and one is modifying the record's data then this
|
---|
89 | modifying instance makes a copy and modifies its private copy -
|
---|
90 | thus it does not affect other instances.
|
---|
91 | <p> <p>See also <a href="qsqlrecordinfo.html">QSqlRecordInfo</a> and <a href="database.html">Database Classes</a>.
|
---|
92 |
|
---|
93 | <hr><h2>Member Function Documentation</h2>
|
---|
94 | <h3 class=fn><a name="QSqlRecord"></a>QSqlRecord::QSqlRecord ()
|
---|
95 | </h3>
|
---|
96 | Constructs an empty record.
|
---|
97 |
|
---|
98 | <h3 class=fn><a name="QSqlRecord-2"></a>QSqlRecord::QSqlRecord ( const <a href="qsqlrecord.html">QSqlRecord</a> & other )
|
---|
99 | </h3>
|
---|
100 | Constructs a copy of <em>other</em>.
|
---|
101 |
|
---|
102 | <h3 class=fn><a name="~QSqlRecord"></a>QSqlRecord::~QSqlRecord ()<tt> [virtual]</tt>
|
---|
103 | </h3>
|
---|
104 | Destroys the object and frees any allocated resources.
|
---|
105 |
|
---|
106 | <h3 class=fn>void <a name="append"></a>QSqlRecord::append ( const <a href="qsqlfield.html">QSqlField</a> & field )<tt> [virtual]</tt>
|
---|
107 | </h3>
|
---|
108 | Append a copy of field <em>field</em> to the end of the record.
|
---|
109 |
|
---|
110 | <p>Reimplemented in <a href="qsqlindex.html#append">QSqlIndex</a>.
|
---|
111 | <h3 class=fn>void <a name="clear"></a>QSqlRecord::clear ()<tt> [virtual]</tt>
|
---|
112 | </h3>
|
---|
113 | Removes all the record's fields.
|
---|
114 | <p> <p>See also <a href="#clearValues">clearValues</a>().
|
---|
115 |
|
---|
116 | <p>Reimplemented in <a href="qsqlcursor.html#clear">QSqlCursor</a>.
|
---|
117 | <h3 class=fn>void <a name="clearValues"></a>QSqlRecord::clearValues ( bool nullify = FALSE )<tt> [virtual]</tt>
|
---|
118 | </h3>
|
---|
119 | Clears the value of all fields in the record. If <em>nullify</em> is
|
---|
120 | TRUE, (the default is FALSE), each field is set to NULL.
|
---|
121 |
|
---|
122 | <h3 class=fn>bool <a name="contains"></a>QSqlRecord::contains ( const <a href="qstring.html">QString</a> & name ) const
|
---|
123 | </h3>
|
---|
124 | Returns TRUE if there is a field in the record called <em>name</em>;
|
---|
125 | otherwise returns FALSE.
|
---|
126 |
|
---|
127 | <h3 class=fn>uint <a name="count"></a>QSqlRecord::count () const
|
---|
128 | </h3>
|
---|
129 | Returns the number of fields in the record.
|
---|
130 |
|
---|
131 | <h3 class=fn><a href="qsqlfield.html">QSqlField</a> * <a name="field"></a>QSqlRecord::field ( int i )
|
---|
132 | </h3>
|
---|
133 | Returns the field at position <em>i</em> within the record, or 0 if it
|
---|
134 | cannot be found.
|
---|
135 |
|
---|
136 | <h3 class=fn><a href="qsqlfield.html">QSqlField</a> * <a name="field-2"></a>QSqlRecord::field ( const <a href="qstring.html">QString</a> & name )
|
---|
137 | </h3>
|
---|
138 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
139 | <p> Returns the field called <em>name</em> within the record, or 0 if it
|
---|
140 | cannot be found. Field names are not case-sensitive.
|
---|
141 |
|
---|
142 | <h3 class=fn>const <a href="qsqlfield.html">QSqlField</a> * <a name="field-3"></a>QSqlRecord::field ( int i ) const
|
---|
143 | </h3>
|
---|
144 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
145 | <p>
|
---|
146 | <h3 class=fn>const <a href="qsqlfield.html">QSqlField</a> * <a name="field-4"></a>QSqlRecord::field ( const <a href="qstring.html">QString</a> & name ) const
|
---|
147 | </h3>
|
---|
148 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
149 | <p> Returns the field called <em>name</em> within the record, or 0 if it
|
---|
150 | cannot be found. Field names are not case-sensitive.
|
---|
151 |
|
---|
152 | <h3 class=fn><a href="qstring.html">QString</a> <a name="fieldName"></a>QSqlRecord::fieldName ( int i ) const
|
---|
153 | </h3>
|
---|
154 | Returns the name of the field at position <em>i</em>. If the field does
|
---|
155 | not exist, <a href="qstring.html#QString-null">QString::null</a> is returned.
|
---|
156 |
|
---|
157 | <h3 class=fn>void <a name="insert"></a>QSqlRecord::insert ( int pos, const <a href="qsqlfield.html">QSqlField</a> & field )<tt> [virtual]</tt>
|
---|
158 | </h3>
|
---|
159 | Insert a copy of <em>field</em> at position <em>pos</em>. If a field already
|
---|
160 | exists at <em>pos</em>, it is removed.
|
---|
161 |
|
---|
162 | <h3 class=fn>bool <a name="isEmpty"></a>QSqlRecord::isEmpty () const
|
---|
163 | </h3>
|
---|
164 | Returns TRUE if there are no fields in the record; otherwise
|
---|
165 | returns FALSE.
|
---|
166 |
|
---|
167 | <h3 class=fn>bool <a name="isGenerated"></a>QSqlRecord::isGenerated ( const <a href="qstring.html">QString</a> & name ) const
|
---|
168 | </h3>
|
---|
169 | Returns TRUE if the record has a field called <em>name</em> and this
|
---|
170 | field is to be generated (the default); otherwise returns FALSE.
|
---|
171 | <p> <p>See also <a href="#setGenerated">setGenerated</a>().
|
---|
172 |
|
---|
173 | <h3 class=fn>bool <a name="isGenerated-2"></a>QSqlRecord::isGenerated ( int i ) const
|
---|
174 | </h3>
|
---|
175 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
176 | <p> Returns TRUE if the record has a field at position <em>i</em> and this
|
---|
177 | field is to be generated (the default); otherwise returns FALSE.
|
---|
178 | <p> <p>See also <a href="#setGenerated">setGenerated</a>().
|
---|
179 |
|
---|
180 | <h3 class=fn>bool <a name="isNull"></a>QSqlRecord::isNull ( const <a href="qstring.html">QString</a> & name ) const
|
---|
181 | </h3>
|
---|
182 | Returns TRUE if the field called <em>name</em> is NULL or if there is no
|
---|
183 | field called <em>name</em>; otherwise returns FALSE.
|
---|
184 | <p> <p>See also <a href="#position">position</a>().
|
---|
185 |
|
---|
186 | <h3 class=fn>bool <a name="isNull-4"></a>QSqlRecord::isNull ( int i ) const
|
---|
187 | </h3>
|
---|
188 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
189 | <p> Returns TRUE if the field <em>i</em> is NULL or if there is no field at
|
---|
190 | position <em>i</em>; otherwise returns FALSE.
|
---|
191 | <p> <p>See also <a href="#fieldName">fieldName</a>().
|
---|
192 |
|
---|
193 | <h3 class=fn><a href="qsqlrecord.html">QSqlRecord</a> & <a name="operator-eq"></a>QSqlRecord::operator= ( const <a href="qsqlrecord.html">QSqlRecord</a> & other )
|
---|
194 | </h3>
|
---|
195 | Sets the record equal to <em>other</em>.
|
---|
196 |
|
---|
197 | <h3 class=fn>int <a name="position"></a>QSqlRecord::position ( const <a href="qstring.html">QString</a> & name ) const
|
---|
198 | </h3>
|
---|
199 | Returns the position of the field called <em>name</em> within the
|
---|
200 | record, or -1 if it cannot be found. Field names are not
|
---|
201 | case-sensitive. If more than one field matches, the first one is
|
---|
202 | returned.
|
---|
203 |
|
---|
204 | <h3 class=fn>void <a name="remove"></a>QSqlRecord::remove ( int pos )<tt> [virtual]</tt>
|
---|
205 | </h3>
|
---|
206 | Removes the field at <em>pos</em>. If <em>pos</em> does not exist, nothing
|
---|
207 | happens.
|
---|
208 |
|
---|
209 | <p>Reimplemented in <a href="qsqlcursor.html#remove">QSqlCursor</a>.
|
---|
210 | <h3 class=fn>void <a name="setGenerated"></a>QSqlRecord::setGenerated ( const <a href="qstring.html">QString</a> & name, bool generated )<tt> [virtual]</tt>
|
---|
211 | </h3>
|
---|
212 | Sets the generated flag for the field called <em>name</em> to <em>generated</em>. If the field does not exist, nothing happens. Only
|
---|
213 | fields that have <em>generated</em> set to TRUE are included in the SQL
|
---|
214 | that is generated, e.g. by <a href="qsqlcursor.html">QSqlCursor</a>.
|
---|
215 | <p> <p>See also <a href="#isGenerated">isGenerated</a>().
|
---|
216 |
|
---|
217 | <p>Reimplemented in <a href="qsqlcursor.html#setGenerated">QSqlCursor</a>.
|
---|
218 | <h3 class=fn>void <a name="setGenerated-2"></a>QSqlRecord::setGenerated ( int i, bool generated )<tt> [virtual]</tt>
|
---|
219 | </h3>
|
---|
220 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
221 | <p> Sets the generated flag for the field <em>i</em> to <em>generated</em>.
|
---|
222 | <p> <p>See also <a href="#isGenerated">isGenerated</a>().
|
---|
223 |
|
---|
224 | <p>Reimplemented in <a href="qsqlcursor.html#setGenerated-2">QSqlCursor</a>.
|
---|
225 | <h3 class=fn>void <a name="setNull"></a>QSqlRecord::setNull ( int i )<tt> [virtual]</tt>
|
---|
226 | </h3>
|
---|
227 | Sets the value of field <em>i</em> to NULL. If the field does not exist,
|
---|
228 | nothing happens.
|
---|
229 |
|
---|
230 | <h3 class=fn>void <a name="setNull-2"></a>QSqlRecord::setNull ( const <a href="qstring.html">QString</a> & name )<tt> [virtual]</tt>
|
---|
231 | </h3>
|
---|
232 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
233 | <p> Sets the value of the field called <em>name</em> to NULL. If the field
|
---|
234 | does not exist, nothing happens.
|
---|
235 |
|
---|
236 | <h3 class=fn>void <a name="setValue"></a>QSqlRecord::setValue ( int i, const <a href="qvariant.html">QVariant</a> & val )<tt> [virtual]</tt>
|
---|
237 | </h3>
|
---|
238 | Sets the value of the field at position <em>i</em> to <em>val</em>. If the
|
---|
239 | field does not exist, nothing happens.
|
---|
240 |
|
---|
241 | <p>Examples: <a href="sql.html#x2196">sql/overview/insert/main.cpp</a>, <a href="qsqlcursor.html#x2448">sql/overview/insert2/main.cpp</a>, <a href="sql.html#x2270">sql/overview/subclass5/main.cpp</a>, <a href="sql.html#x2203">sql/overview/update/main.cpp</a>, and <a href="sqltable-example.html#x2464">sql/sqltable/main.cpp</a>.
|
---|
242 | <h3 class=fn>void <a name="setValue-2"></a>QSqlRecord::setValue ( const <a href="qstring.html">QString</a> & name, const <a href="qvariant.html">QVariant</a> & val )<tt> [virtual]</tt>
|
---|
243 | </h3>
|
---|
244 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
245 | <p> Sets the value of the field called <em>name</em> to <em>val</em>. If the field
|
---|
246 | does not exist, nothing happens.
|
---|
247 |
|
---|
248 | <h3 class=fn><a href="qstring.html">QString</a> <a name="toString"></a>QSqlRecord::toString ( const <a href="qstring.html">QString</a> & prefix = QString::null, const <a href="qstring.html">QString</a> & sep = "," ) const<tt> [virtual]</tt>
|
---|
249 | </h3>
|
---|
250 | Returns a list of all the record's field names as a string
|
---|
251 | separated by <em>sep</em>.
|
---|
252 | <p> Note that fields which are not generated are <em>not</em> included (see
|
---|
253 | <a href="#isGenerated">isGenerated</a>()). The returned string is suitable, for example, for
|
---|
254 | generating SQL SELECT statements. If a <em>prefix</em> is specified,
|
---|
255 | e.g. a table name, all fields are prefixed in the form:
|
---|
256 | <p> "<em>prefix</em>.<fieldname>"
|
---|
257 |
|
---|
258 | <h3 class=fn><a href="qstringlist.html">QStringList</a> <a name="toStringList"></a>QSqlRecord::toStringList ( const <a href="qstring.html">QString</a> & prefix = QString::null ) const<tt> [virtual]</tt>
|
---|
259 | </h3>
|
---|
260 | Returns a list of all the record's field names, each having the
|
---|
261 | prefix <em>prefix</em>.
|
---|
262 | <p> Note that fields which have generated set to FALSE are <em>not</em>
|
---|
263 | included. (See <a href="#isGenerated">isGenerated</a>()). If <em>prefix</em> is supplied, e.g.
|
---|
264 | a table name, all fields are prefixed in the form:
|
---|
265 | <p> "<em>prefix</em>.<fieldname>"
|
---|
266 |
|
---|
267 | <h3 class=fn><a href="qvariant.html">QVariant</a> <a name="value"></a>QSqlRecord::value ( int i ) const<tt> [virtual]</tt>
|
---|
268 | </h3>
|
---|
269 | Returns the value of the field located at position <em>i</em> in the
|
---|
270 | record. If field <em>i</em> does not exist the resultant behaviour is
|
---|
271 | undefined.
|
---|
272 | <p> This function should be used with <a href="qsqlquery.html">QSqlQuery</a>s. When working
|
---|
273 | with a <a href="qsqlcursor.html">QSqlCursor</a> the <a href="qsqlquery.html#value">value(const
|
---|
274 | QString&)</a> overload which uses field names is more
|
---|
275 | appropriate.
|
---|
276 |
|
---|
277 | <p>Example: <a href="sql.html#x2204">sql/overview/update/main.cpp</a>.
|
---|
278 | <h3 class=fn><a href="qvariant.html">QVariant</a> <a name="value-2"></a>QSqlRecord::value ( const <a href="qstring.html">QString</a> & name ) const<tt> [virtual]</tt>
|
---|
279 | </h3>
|
---|
280 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
281 | <p> Returns the value of the field called <em>name</em> in the record. If
|
---|
282 | field <em>name</em> does not exist the resultant behaviour is undefined.
|
---|
283 |
|
---|
284 | <!-- eof -->
|
---|
285 | <hr><p>
|
---|
286 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
287 | Copyright © 1995-2007
|
---|
288 | <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
---|
289 | <table width=100% cellspacing=0 border=0><tr>
|
---|
290 | <td>Copyright © 2007
|
---|
291 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
292 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
293 | </table></div></address></body>
|
---|
294 | </html>
|
---|