~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/qsqlrecord.html

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html
 
3
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
 
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/src/sql/kernel/qsqlrecord.cpp -->
 
6
<head>
 
7
    <title>Qt 4.0: QSqlRecord Class Reference</title>
 
8
    <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
 
9
a:link { color: #004faf; text-decoration: none }
 
10
a:visited { color: #672967; text-decoration: none }
 
11
td.postheader { font-family: sans-serif }
 
12
tr.address { font-family: sans-serif }
 
13
body { background: #ffffff; color: black; }</style>
 
14
</head>
 
15
<body>
 
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
17
<tr>
 
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
 
19
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="annotated.html"><font color="#004faf">Annotated</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
 
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">QSqlRecord Class Reference</h1>
 
21
<p>The QSqlRecord class encapsulates a database record. <a href="#details">More...</a></p>
 
22
<pre>#include &lt;QSqlRecord&gt;</pre><p>Part of the <a href="qtsql.html">QtSql</a> module.</p>
 
23
<p>Inherited by <a href="q3sqlcursor.html">Q3SqlCursor</a> and <a href="qsqlindex.html">QSqlIndex</a>.</p>
 
24
<ul>
 
25
<li><a href="qsqlrecord-members.html">List of all members, including inherited members</a></li>
 
26
<li><a href="qsqlrecord-qt3.html">Qt 3 support members</a></li>
 
27
</ul>
 
28
<a name="public-functions"></a>
 
29
<h3>Public Functions</h3>
 
30
<ul>
 
31
<li><div class="fn"/><b><a href="qsqlrecord.html#QSqlRecord">QSqlRecord</a></b> ()</li>
 
32
<li><div class="fn"/><b><a href="qsqlrecord.html#QSqlRecord-2">QSqlRecord</a></b> ( const QSqlRecord &amp; <i>other</i> )</li>
 
33
<li><div class="fn"/><b><a href="qsqlrecord.html#dtor.QSqlRecord">~QSqlRecord</a></b> ()</li>
 
34
<li><div class="fn"/>void <b><a href="qsqlrecord.html#append">append</a></b> ( const QSqlField &amp; <i>field</i> )</li>
 
35
<li><div class="fn"/>void <b><a href="qsqlrecord.html#clear">clear</a></b> ()</li>
 
36
<li><div class="fn"/>void <b><a href="qsqlrecord.html#clearValues">clearValues</a></b> ()</li>
 
37
<li><div class="fn"/>bool <b><a href="qsqlrecord.html#contains">contains</a></b> ( const QString &amp; <i>name</i> ) const</li>
 
38
<li><div class="fn"/>int <b><a href="qsqlrecord.html#count">count</a></b> () const</li>
 
39
<li><div class="fn"/>QSqlField <b><a href="qsqlrecord.html#field">field</a></b> ( int <i>index</i> ) const</li>
 
40
<li><div class="fn"/>QSqlField <b><a href="qsqlrecord.html#field-2">field</a></b> ( const QString &amp; <i>name</i> ) const</li>
 
41
<li><div class="fn"/>QString <b><a href="qsqlrecord.html#fieldName">fieldName</a></b> ( int <i>index</i> ) const</li>
 
42
<li><div class="fn"/>int <b><a href="qsqlrecord.html#indexOf">indexOf</a></b> ( const QString &amp; <i>name</i> ) const</li>
 
43
<li><div class="fn"/>void <b><a href="qsqlrecord.html#insert">insert</a></b> ( int <i>pos</i>, const QSqlField &amp; <i>field</i> )</li>
 
44
<li><div class="fn"/>bool <b><a href="qsqlrecord.html#isEmpty">isEmpty</a></b> () const</li>
 
45
<li><div class="fn"/>bool <b><a href="qsqlrecord.html#isGenerated">isGenerated</a></b> ( const QString &amp; <i>name</i> ) const</li>
 
46
<li><div class="fn"/>bool <b><a href="qsqlrecord.html#isGenerated-2">isGenerated</a></b> ( int <i>index</i> ) const</li>
 
47
<li><div class="fn"/>bool <b><a href="qsqlrecord.html#isNull">isNull</a></b> ( const QString &amp; <i>name</i> ) const</li>
 
48
<li><div class="fn"/>bool <b><a href="qsqlrecord.html#isNull-2">isNull</a></b> ( int <i>index</i> ) const</li>
 
49
<li><div class="fn"/>void <b><a href="qsqlrecord.html#remove">remove</a></b> ( int <i>pos</i> )</li>
 
50
<li><div class="fn"/>void <b><a href="qsqlrecord.html#replace">replace</a></b> ( int <i>pos</i>, const QSqlField &amp; <i>field</i> )</li>
 
51
<li><div class="fn"/>void <b><a href="qsqlrecord.html#setGenerated">setGenerated</a></b> ( const QString &amp; <i>name</i>, bool <i>generated</i> )</li>
 
52
<li><div class="fn"/>void <b><a href="qsqlrecord.html#setGenerated-2">setGenerated</a></b> ( int <i>index</i>, bool <i>generated</i> )</li>
 
53
<li><div class="fn"/>void <b><a href="qsqlrecord.html#setNull">setNull</a></b> ( int <i>index</i> )</li>
 
54
<li><div class="fn"/>void <b><a href="qsqlrecord.html#setNull-2">setNull</a></b> ( const QString &amp; <i>name</i> )</li>
 
55
<li><div class="fn"/>void <b><a href="qsqlrecord.html#setValue">setValue</a></b> ( int <i>index</i>, const QVariant &amp; <i>val</i> )</li>
 
56
<li><div class="fn"/>void <b><a href="qsqlrecord.html#setValue-2">setValue</a></b> ( const QString &amp; <i>name</i>, const QVariant &amp; <i>val</i> )</li>
 
57
<li><div class="fn"/>QVariant <b><a href="qsqlrecord.html#value">value</a></b> ( int <i>index</i> ) const</li>
 
58
<li><div class="fn"/>QVariant <b><a href="qsqlrecord.html#value-2">value</a></b> ( const QString &amp; <i>name</i> ) const</li>
 
59
<li><div class="fn"/>bool <b><a href="qsqlrecord.html#operator-not-eq">operator!=</a></b> ( const QSqlRecord &amp; <i>other</i> ) const</li>
 
60
<li><div class="fn"/>QSqlRecord &amp; <b><a href="qsqlrecord.html#operator-eq">operator=</a></b> ( const QSqlRecord &amp; <i>other</i> )</li>
 
61
<li><div class="fn"/>bool <b><a href="qsqlrecord.html#operator-eq-eq">operator==</a></b> ( const QSqlRecord &amp; <i>other</i> ) const</li>
 
62
</ul>
 
63
<a name="details"></a>
 
64
<hr />
 
65
<h2>Detailed Description</h2>
 
66
<p>The QSqlRecord class encapsulates a database record.</p>
 
67
<p>The QSqlRecord class encapsulates the functionality and characteristics of a database record (usually a row in a table or view within the database). QSqlRecord supports adding and removing fields as well as setting and retrieving field values.</p>
 
68
<p>The values of a record's fields' can be set by name or position with <a href="qsqlrecord.html#setValue">setValue</a>(); if you want to set a field to null use <a href="qsqlrecord.html#setNull">setNull</a>(). To find the position of a field by name use <a href="qsqlrecord.html#indexOf">indexOf</a>(), and to find the name of a field at a particular position use <a href="qsqlrecord.html#fieldName">fieldName</a>(). Use <a href="qsqlrecord.html#field">field</a>() to retrieve a <a href="qsqlfield.html">QSqlField</a> object for a given field. Use <a href="qsqlrecord.html#contains">contains</a>() to see if the record contains a particular field name.</p>
 
69
<p>When queries are generated to be executed on the database only those fields for which <a href="qsqlrecord.html#isGenerated">isGenerated</a>() is true are included in the generated SQL.</p>
 
70
<p>A record can have fields added with <a href="qsqlrecord.html#append">append</a>() or <a href="qsqlrecord.html#insert">insert</a>(), replaced with <a href="qsqlrecord.html#replace">replace</a>(), and removed with <a href="qsqlrecord.html#remove">remove</a>(). All the fields can be removed with <a href="qsqlrecord.html#clear">clear</a>(). The number of fields is given by <a href="qsqlrecord.html#count">count</a>(); all their values can be cleared (to null) using <a href="qsqlrecord.html#clearValues">clearValues</a>().</p>
 
71
<p>See also <a href="qsqlfield.html">QSqlField</a> and <a href="qsqlquery.html#record">QSqlQuery::record</a>().</p>
 
72
<hr />
 
73
<h2>Member Function Documentation</h2>
 
74
<h3 class="fn"><a name="QSqlRecord"></a>QSqlRecord::QSqlRecord ()</h3>
 
75
<p>Constructs an empty record.</p>
 
76
<p>See also <a href="qsqlrecord.html#isEmpty">isEmpty</a>(), <a href="qsqlrecord.html#append">append</a>(), and <a href="qsqlrecord.html#insert">insert</a>().</p>
 
77
<h3 class="fn"><a name="QSqlRecord-2"></a>QSqlRecord::QSqlRecord ( const QSqlRecord &amp; <i>other</i> )</h3>
 
78
<p>Constructs a copy of <i>other</i>.</p>
 
79
<p><a href="qsqlrecord.html">QSqlRecord</a> is <a href="shclass.html#implicitly-shared">implicitly shared</a>. This means you can make copies of a record in <a href="containers.html#constant-time">constant time</a>.</p>
 
80
<h3 class="fn"><a name="dtor.QSqlRecord"></a>QSqlRecord::~QSqlRecord ()</h3>
 
81
<p>Destroys the object and frees any allocated resources.</p>
 
82
<h3 class="fn"><a name="append"></a>void QSqlRecord::append ( const <a href="qsqlfield.html">QSqlField</a> &amp; <i>field</i> )</h3>
 
83
<p>Append a copy of field <i>field</i> to the end of the record.</p>
 
84
<p>See also <a href="qsqlrecord.html#insert">insert</a>(), <a href="qsqlrecord.html#replace">replace</a>(), and <a href="qsqlrecord.html#remove">remove</a>().</p>
 
85
<h3 class="fn"><a name="clear"></a>void QSqlRecord::clear ()</h3>
 
86
<p>Removes all the record's fields.</p>
 
87
<p>See also <a href="qsqlrecord.html#clearValues">clearValues</a>() and <a href="qsqlrecord.html#isEmpty">isEmpty</a>().</p>
 
88
<h3 class="fn"><a name="clearValues"></a>void QSqlRecord::clearValues ()</h3>
 
89
<p>Clears the value of all fields in the record and sets each field to null.</p>
 
90
<p>See also <a href="qsqlrecord.html#setValue">setValue</a>().</p>
 
91
<h3 class="fn"><a name="contains"></a>bool QSqlRecord::contains ( const <a href="qstring.html">QString</a> &amp; <i>name</i> ) const</h3>
 
92
<p>Returns true if there is a field in the record called <i>name</i>; otherwise returns false.</p>
 
93
<h3 class="fn"><a name="count"></a>int QSqlRecord::count () const</h3>
 
94
<p>Returns the number of fields in the record.</p>
 
95
<p>See also <a href="qsqlrecord.html#isEmpty">isEmpty</a>().</p>
 
96
<h3 class="fn"><a name="field"></a><a href="qsqlfield.html">QSqlField</a> QSqlRecord::field ( int <i>index</i> ) const</h3>
 
97
<p>Returns the field at position <i>index</i>. If the position is out of range, an empty field is returned.</p>
 
98
<h3 class="fn"><a name="field-2"></a><a href="qsqlfield.html">QSqlField</a> QSqlRecord::field ( const <a href="qstring.html">QString</a> &amp; <i>name</i> ) const</h3>
 
99
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
100
<p>Returns the field called <i>name</i>.</p>
 
101
<h3 class="fn"><a name="fieldName"></a><a href="qstring.html">QString</a> QSqlRecord::fieldName ( int <i>index</i> ) const</h3>
 
102
<p>Returns the name of the field at position <i>index</i>. If the field does not exist, an empty string is returned.</p>
 
103
<p>See also <a href="qsqlrecord.html#indexOf">indexOf</a>().</p>
 
104
<h3 class="fn"><a name="indexOf"></a>int QSqlRecord::indexOf ( const <a href="qstring.html">QString</a> &amp; <i>name</i> ) const</h3>
 
105
<p>Returns the position of the field called <i>name</i> within the record, or -1 if it cannot be found. Field names are not case-sensitive. If more than one field matches, the first one is returned.</p>
 
106
<p>See also <a href="qsqlrecord.html#fieldName">fieldName</a>().</p>
 
107
<h3 class="fn"><a name="insert"></a>void QSqlRecord::insert ( int <i>pos</i>, const <a href="qsqlfield.html">QSqlField</a> &amp; <i>field</i> )</h3>
 
108
<p>Inserts the field <i>field</i> at position <i>pos</i> in the record.</p>
 
109
<p>See also <a href="qsqlrecord.html#append">append</a>(), <a href="qsqlrecord.html#replace">replace</a>(), and <a href="qsqlrecord.html#remove">remove</a>().</p>
 
110
<h3 class="fn"><a name="isEmpty"></a>bool QSqlRecord::isEmpty () const</h3>
 
111
<p>Returns true if there are no fields in the record; otherwise returns false.</p>
 
112
<p>See also <a href="qsqlrecord.html#append">append</a>(), <a href="qsqlrecord.html#insert">insert</a>(), and <a href="qsqlrecord.html#clear">clear</a>().</p>
 
113
<h3 class="fn"><a name="isGenerated"></a>bool QSqlRecord::isGenerated ( const <a href="qstring.html">QString</a> &amp; <i>name</i> ) const</h3>
 
114
<p>Returns true if the record has a field called <i>name</i> and this field is to be generated (the default); otherwise returns false.</p>
 
115
<p>See also <a href="qsqlrecord.html#setGenerated">setGenerated</a>().</p>
 
116
<h3 class="fn"><a name="isGenerated-2"></a>bool QSqlRecord::isGenerated ( int <i>index</i> ) const</h3>
 
117
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
118
<p>Returns true if the record has a field at position <i>index</i> and this field is to be generated (the default); otherwise returns false.</p>
 
119
<p>See also <a href="qsqlrecord.html#setGenerated">setGenerated</a>().</p>
 
120
<h3 class="fn"><a name="isNull"></a>bool QSqlRecord::isNull ( const <a href="qstring.html">QString</a> &amp; <i>name</i> ) const</h3>
 
121
<p>Returns true if the field called <i>name</i> is null or if there is no field called <i>name</i>; otherwise returns false.</p>
 
122
<p>See also <a href="qsqlrecord.html#setNull">setNull</a>().</p>
 
123
<h3 class="fn"><a name="isNull-2"></a>bool QSqlRecord::isNull ( int <i>index</i> ) const</h3>
 
124
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
125
<p>Returns true if the field <i>index</i> is null or if there is no field at position <i>index</i>; otherwise returns false.</p>
 
126
<h3 class="fn"><a name="remove"></a>void QSqlRecord::remove ( int <i>pos</i> )</h3>
 
127
<p>Removes the field at position <i>pos</i>. If <i>pos</i> is out of range, nothing happens.</p>
 
128
<p>See also <a href="qsqlrecord.html#append">append</a>(), <a href="qsqlrecord.html#insert">insert</a>(), and <a href="qsqlrecord.html#replace">replace</a>().</p>
 
129
<h3 class="fn"><a name="replace"></a>void QSqlRecord::replace ( int <i>pos</i>, const <a href="qsqlfield.html">QSqlField</a> &amp; <i>field</i> )</h3>
 
130
<p>Replaces the field at position <i>pos</i> with the given <i>field</i>. If <i>pos</i> is out of range, nothing happens.</p>
 
131
<p>See also <a href="qsqlrecord.html#append">append</a>(), <a href="qsqlrecord.html#insert">insert</a>(), and <a href="qsqlrecord.html#remove">remove</a>().</p>
 
132
<h3 class="fn"><a name="setGenerated"></a>void QSqlRecord::setGenerated ( const <a href="qstring.html">QString</a> &amp; <i>name</i>, bool <i>generated</i> )</h3>
 
133
<p>Sets the generated flag for the field called <i>name</i> to <i>generated</i>. If the field does not exist, nothing happens. Only fields that have <i>generated</i> set to true are included in the SQL that is generated by <a href="qsqlquerymodel.html">QSqlQueryModel</a> for example.</p>
 
134
<p>See also <a href="qsqlrecord.html#isGenerated">isGenerated</a>().</p>
 
135
<h3 class="fn"><a name="setGenerated-2"></a>void QSqlRecord::setGenerated ( int <i>index</i>, bool <i>generated</i> )</h3>
 
136
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
137
<p>Sets the generated flag for the field <i>index</i> to <i>generated</i>.</p>
 
138
<p>See also <a href="qsqlrecord.html#isGenerated">isGenerated</a>().</p>
 
139
<h3 class="fn"><a name="setNull"></a>void QSqlRecord::setNull ( int <i>index</i> )</h3>
 
140
<p>Sets the value of field <i>index</i> to null. If the field does not exist, nothing happens.</p>
 
141
<p>See also <a href="qsqlrecord.html#setValue">setValue</a>().</p>
 
142
<h3 class="fn"><a name="setNull-2"></a>void QSqlRecord::setNull ( const <a href="qstring.html">QString</a> &amp; <i>name</i> )</h3>
 
143
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
144
<p>Sets the value of the field called <i>name</i> to null. If the field does not exist, nothing happens.</p>
 
145
<h3 class="fn"><a name="setValue"></a>void QSqlRecord::setValue ( int <i>index</i>, const <a href="qvariant.html">QVariant</a> &amp; <i>val</i> )</h3>
 
146
<p>Sets the value of the field at position <i>index</i> to <i>val</i>. If the field does not exist, nothing happens.</p>
 
147
<p>See also <a href="qsqlrecord.html#setNull">setNull</a>().</p>
 
148
<h3 class="fn"><a name="setValue-2"></a>void QSqlRecord::setValue ( const <a href="qstring.html">QString</a> &amp; <i>name</i>, const <a href="qvariant.html">QVariant</a> &amp; <i>val</i> )</h3>
 
149
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
150
<p>Sets the value of the field called <i>name</i> to <i>val</i>. If the field does not exist, nothing happens.</p>
 
151
<h3 class="fn"><a name="value"></a><a href="qvariant.html">QVariant</a> QSqlRecord::value ( int <i>index</i> ) const</h3>
 
152
<p>Returns the value of the field located at position <i>index</i> in the record. If <i>index</i> is out of bounds, an invalid <a href="qvariant.html">QVariant</a> is returned.</p>
 
153
<p>See also <a href="qsqlrecord.html#fieldName">fieldName</a>() and <a href="qsqlrecord.html#isNull">isNull</a>().</p>
 
154
<h3 class="fn"><a name="value-2"></a><a href="qvariant.html">QVariant</a> QSqlRecord::value ( const <a href="qstring.html">QString</a> &amp; <i>name</i> ) const</h3>
 
155
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
156
<p>Returns the value of the field called <i>name</i> in the record. If field <i>name</i> does not exist an invalid variant is returned.</p>
 
157
<p>See also <a href="qsqlrecord.html#indexOf">indexOf</a>().</p>
 
158
<h3 class="fn"><a name="operator-not-eq"></a>bool QSqlRecord::operator!= ( const QSqlRecord &amp; <i>other</i> ) const</h3>
 
159
<p>Returns true if this object is not identical to <i>other</i>; otherwise returns false.</p>
 
160
<p>See also <a href="qsqlrecord.html#operator-eq-eq">operator==</a>().</p>
 
161
<h3 class="fn"><a name="operator-eq"></a>QSqlRecord &amp; QSqlRecord::operator= ( const QSqlRecord &amp; <i>other</i> )</h3>
 
162
<p>Sets the record equal to <i>other</i>.</p>
 
163
<p><a href="qsqlrecord.html">QSqlRecord</a> is <a href="shclass.html#implicitly-shared">implicitly shared</a>. This means you can make copies of a record in <a href="containers.html#constant-time">constant time</a>.</p>
 
164
<h3 class="fn"><a name="operator-eq-eq"></a>bool QSqlRecord::operator== ( const QSqlRecord &amp; <i>other</i> ) const</h3>
 
165
<p>Returns true if this object is identical to <i>other</i> (i.e., has the same fields in the same order); otherwise returns false.</p>
 
166
<p>See also <a href="qsqlrecord.html#operator-not-eq">operator!=</a>().</p>
 
167
<p /><address><hr /><div align="center">
 
168
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
169
<td width="30%">Copyright &copy; 2005 <a href="trolltech.html">Trolltech</a></td>
 
170
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
171
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
 
172
</tr></table></div></address></body>
 
173
</html>