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
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QSqlRecord Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><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="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QSqlRecord Class Reference<br /><sup><sup>[<a href="qtsql.html">QtSql</a> module]</sup></sup></h1><p>The QSqlRecord class encapsulates a database record. <a href="#details">More...</a></p>
<p>Inherited by <a href="qsqlindex.html">QSqlIndex</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qsqlrecord.html#QSqlRecord">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qsqlrecord.html#QSqlRecord-2">__init__</a></b> (<i>self</i>, QSqlRecord <i>other</i>)</li><li><div class="fn" /><b><a href="qsqlrecord.html#append">append</a></b> (<i>self</i>, QSqlField <i>field</i>)</li><li><div class="fn" /><b><a href="qsqlrecord.html#clear">clear</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qsqlrecord.html#clearValues">clearValues</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsqlrecord.html#contains">contains</a></b> (<i>self</i>, QString <i>name</i>)</li><li><div class="fn" />int <b><a href="qsqlrecord.html#count">count</a></b> (<i>self</i>)</li><li><div class="fn" />QSqlField <b><a href="qsqlrecord.html#field">field</a></b> (<i>self</i>, int <i>i</i>)</li><li><div class="fn" />QSqlField <b><a href="qsqlrecord.html#field-2">field</a></b> (<i>self</i>, QString <i>name</i>)</li><li><div class="fn" />QString <b><a href="qsqlrecord.html#fieldName">fieldName</a></b> (<i>self</i>, int <i>i</i>)</li><li><div class="fn" />int <b><a href="qsqlrecord.html#indexOf">indexOf</a></b> (<i>self</i>, QString <i>name</i>)</li><li><div class="fn" /><b><a href="qsqlrecord.html#insert">insert</a></b> (<i>self</i>, int <i>pos</i>, QSqlField <i>field</i>)</li><li><div class="fn" />bool <b><a href="qsqlrecord.html#isEmpty">isEmpty</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsqlrecord.html#isGenerated">isGenerated</a></b> (<i>self</i>, int <i>i</i>)</li><li><div class="fn" />bool <b><a href="qsqlrecord.html#isGenerated-2">isGenerated</a></b> (<i>self</i>, QString <i>name</i>)</li><li><div class="fn" />bool <b><a href="qsqlrecord.html#isNull">isNull</a></b> (<i>self</i>, int <i>i</i>)</li><li><div class="fn" />bool <b><a href="qsqlrecord.html#isNull-2">isNull</a></b> (<i>self</i>, QString <i>name</i>)</li><li><div class="fn" /><b><a href="qsqlrecord.html#remove">remove</a></b> (<i>self</i>, int <i>pos</i>)</li><li><div class="fn" /><b><a href="qsqlrecord.html#replace">replace</a></b> (<i>self</i>, int <i>pos</i>, QSqlField <i>field</i>)</li><li><div class="fn" /><b><a href="qsqlrecord.html#setGenerated">setGenerated</a></b> (<i>self</i>, QString <i>name</i>, bool <i>generated</i>)</li><li><div class="fn" /><b><a href="qsqlrecord.html#setGenerated-2">setGenerated</a></b> (<i>self</i>, int <i>i</i>, bool <i>generated</i>)</li><li><div class="fn" /><b><a href="qsqlrecord.html#setNull">setNull</a></b> (<i>self</i>, int <i>i</i>)</li><li><div class="fn" /><b><a href="qsqlrecord.html#setNull-2">setNull</a></b> (<i>self</i>, QString <i>name</i>)</li><li><div class="fn" /><b><a href="qsqlrecord.html#setValue">setValue</a></b> (<i>self</i>, int <i>i</i>, QVariant <i>val</i>)</li><li><div class="fn" /><b><a href="qsqlrecord.html#setValue-2">setValue</a></b> (<i>self</i>, QString <i>name</i>, QVariant <i>val</i>)</li><li><div class="fn" />QVariant <b><a href="qsqlrecord.html#value">value</a></b> (<i>self</i>, int <i>i</i>)</li><li><div class="fn" />QVariant <b><a href="qsqlrecord.html#value-2">value</a></b> (<i>self</i>, QString <i>name</i>)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" />bool <b><a href="qsqlrecord.html#__eq__">__eq__</a></b> (<i>self</i>, QSqlRecord <i>other</i>)</li><li><div class="fn" />int <b><a href="qsqlrecord.html#__len__">__len__</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsqlrecord.html#__ne__">__ne__</a></b> (<i>self</i>, QSqlRecord <i>other</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QSqlRecord class encapsulates a database record.</p>
<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>
<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>
<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>
<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>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QSqlRecord" />QSqlRecord.__init__ (<i>self</i>)</h3><p>Constructs an empty record.</p>
<p><b>See also</b> <a href="qsqlrecord.html#isEmpty">isEmpty</a>(),
<a href="qsqlrecord.html#append">append</a>(), and <a href="qsqlrecord.html#insert">insert</a>().</p>
<h3 class="fn"><a name="QSqlRecord-2" />QSqlRecord.__init__ (<i>self</i>, <a href="qsqlrecord.html">QSqlRecord</a> <i>other</i>)</h3><p>Constructs a copy of <i>other</i>.</p>
<p><a href="qsqlrecord.html">QSqlRecord</a> is <a href="implicit-sharing.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>
<h3 class="fn"><a name="append" />QSqlRecord.append (<i>self</i>, <a href="qsqlfield.html">QSqlField</a> <i>field</i>)</h3><p>Append a copy of field <i>field</i> to the end of the
record.</p>
<p><b>See also</b> <a href="qsqlrecord.html#insert">insert</a>(),
<a href="qsqlrecord.html#replace">replace</a>(), and <a href="qsqlrecord.html#remove">remove</a>().</p>
<h3 class="fn"><a name="clear" />QSqlRecord.clear (<i>self</i>)</h3><p>Removes all the record's fields.</p>
<p><b>See also</b> <a href="qsqlrecord.html#clearValues">clearValues</a>() and <a href="qsqlrecord.html#isEmpty">isEmpty</a>().</p>
<h3 class="fn"><a name="clearValues" />QSqlRecord.clearValues (<i>self</i>)</h3><p>Clears the value of all fields in the record and sets each field
to null.</p>
<p><b>See also</b> <a href="qsqlrecord.html#setValue">setValue</a>().</p>
<h3 class="fn"><a name="contains" />bool QSqlRecord.contains (<i>self</i>, QString <i>name</i>)</h3><p>Returns true if there is a field in the record called
<i>name</i>; otherwise returns false.</p>
<h3 class="fn"><a name="count" />int QSqlRecord.count (<i>self</i>)</h3><p>Returns the number of fields in the record.</p>
<p><b>See also</b> <a href="qsqlrecord.html#isEmpty">isEmpty</a>().</p>
<h3 class="fn"><a name="field" /><a href="qsqlfield.html">QSqlField</a> QSqlRecord.field (<i>self</i>, int <i>i</i>)</h3><p>Returns the field at position <i>index</i>. If the <i>index</i>
is out of range, function returns a <a href="containers.html#default-constructed-values">default-constructed
value</a>.</p>
<h3 class="fn"><a name="field-2" /><a href="qsqlfield.html">QSqlField</a> QSqlRecord.field (<i>self</i>, QString <i>name</i>)</h3><p>This is an overloaded function.</p>
<p>Returns the field called <i>name</i>.</p>
<h3 class="fn"><a name="fieldName" />QString QSqlRecord.fieldName (<i>self</i>, int <i>i</i>)</h3><p>Returns the name of the field at position <i>index</i>. If the
field does not exist, an empty string is returned.</p>
<p><b>See also</b> <a href="qsqlrecord.html#indexOf">indexOf</a>().</p>
<h3 class="fn"><a name="indexOf" />int QSqlRecord.indexOf (<i>self</i>, QString <i>name</i>)</h3><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>
<p><b>See also</b> <a href="qsqlrecord.html#fieldName">fieldName</a>().</p>
<h3 class="fn"><a name="insert" />QSqlRecord.insert (<i>self</i>, int <i>pos</i>, <a href="qsqlfield.html">QSqlField</a> <i>field</i>)</h3><p>Inserts the field <i>field</i> at position <i>pos</i> in the
record.</p>
<p><b>See also</b> <a href="qsqlrecord.html#append">append</a>(),
<a href="qsqlrecord.html#replace">replace</a>(), and <a href="qsqlrecord.html#remove">remove</a>().</p>
<h3 class="fn"><a name="isEmpty" />bool QSqlRecord.isEmpty (<i>self</i>)</h3><p>Returns true if there are no fields in the record; otherwise
returns false.</p>
<p><b>See also</b> <a href="qsqlrecord.html#append">append</a>(),
<a href="qsqlrecord.html#insert">insert</a>(), and <a href="qsqlrecord.html#clear">clear</a>().</p>
<h3 class="fn"><a name="isGenerated" />bool QSqlRecord.isGenerated (<i>self</i>, int <i>i</i>)</h3><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>
<p><b>See also</b> <a href="qsqlrecord.html#setGenerated">setGenerated</a>().</p>
<h3 class="fn"><a name="isGenerated-2" />bool QSqlRecord.isGenerated (<i>self</i>, QString <i>name</i>)</h3><p>This is an overloaded function.</p>
<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>
<p><b>See also</b> <a href="qsqlrecord.html#setGenerated">setGenerated</a>().</p>
<h3 class="fn"><a name="isNull" />bool QSqlRecord.isNull (<i>self</i>, int <i>i</i>)</h3><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>
<p><b>See also</b> <a href="qsqlrecord.html#setNull">setNull</a>().</p>
<h3 class="fn"><a name="isNull-2" />bool QSqlRecord.isNull (<i>self</i>, QString <i>name</i>)</h3><p>This is an overloaded function.</p>
<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>
<h3 class="fn"><a name="remove" />QSqlRecord.remove (<i>self</i>, int <i>pos</i>)</h3><p>Removes the field at position <i>pos</i>. If <i>pos</i> is out
of range, nothing happens.</p>
<p><b>See also</b> <a href="qsqlrecord.html#append">append</a>(),
<a href="qsqlrecord.html#insert">insert</a>(), and <a href="qsqlrecord.html#replace">replace</a>().</p>
<h3 class="fn"><a name="replace" />QSqlRecord.replace (<i>self</i>, int <i>pos</i>, <a href="qsqlfield.html">QSqlField</a> <i>field</i>)</h3><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>
<p><b>See also</b> <a href="qsqlrecord.html#append">append</a>(),
<a href="qsqlrecord.html#insert">insert</a>(), and <a href="qsqlrecord.html#remove">remove</a>().</p>
<h3 class="fn"><a name="setGenerated" />QSqlRecord.setGenerated (<i>self</i>, QString <i>name</i>, bool <i>generated</i>)</h3><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>
<p><b>See also</b> <a href="qsqlrecord.html#isGenerated">isGenerated</a>().</p>
<h3 class="fn"><a name="setGenerated-2" />QSqlRecord.setGenerated (<i>self</i>, int <i>i</i>, bool <i>generated</i>)</h3><p>This is an overloaded function.</p>
<p>Sets the generated flag for the field <i>index</i> to
<i>generated</i>.</p>
<p><b>See also</b> <a href="qsqlrecord.html#isGenerated">isGenerated</a>().</p>
<h3 class="fn"><a name="setNull" />QSqlRecord.setNull (<i>self</i>, int <i>i</i>)</h3><p>Sets the value of field <i>index</i> to null. If the field does
not exist, nothing happens.</p>
<p><b>See also</b> <a href="qsqlrecord.html#isNull">isNull</a>()
and <a href="qsqlrecord.html#setValue">setValue</a>().</p>
<h3 class="fn"><a name="setNull-2" />QSqlRecord.setNull (<i>self</i>, QString <i>name</i>)</h3><p>This is an overloaded function.</p>
<p>Sets the value of the field called <i>name</i> to null. If the
field does not exist, nothing happens.</p>
<h3 class="fn"><a name="setValue" />QSqlRecord.setValue (<i>self</i>, int <i>i</i>, QVariant <i>val</i>)</h3><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>
<p><b>See also</b> <a href="qsqlrecord.html#value">value</a>() and
<a href="qsqlrecord.html#setNull">setNull</a>().</p>
<h3 class="fn"><a name="setValue-2" />QSqlRecord.setValue (<i>self</i>, QString <i>name</i>, QVariant <i>val</i>)</h3><p>This is an overloaded function.</p>
<p>Sets the value of the field called <i>name</i> to <i>val</i>. If
the field does not exist, nothing happens.</p>
<h3 class="fn"><a name="value" />QVariant QSqlRecord.value (<i>self</i>, int <i>i</i>)</h3><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>
<p><b>See also</b> <a href="qsqlrecord.html#setValue">setValue</a>(), <a href="qsqlrecord.html#fieldName">fieldName</a>(), and <a href="qsqlrecord.html#isNull">isNull</a>().</p>
<h3 class="fn"><a name="value-2" />QVariant QSqlRecord.value (<i>self</i>, QString <i>name</i>)</h3><p>This is an overloaded function.</p>
<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>
<p><b>See also</b> <a href="qsqlrecord.html#indexOf">indexOf</a>().</p>
<h3 class="fn"><a name="__eq__" />bool QSqlRecord.__eq__ (<i>self</i>, <a href="qsqlrecord.html">QSqlRecord</a> <i>other</i>)</h3><h3 class="fn"><a name="__len__" />int QSqlRecord.__len__ (<i>self</i>)</h3><h3 class="fn"><a name="__ne__" />bool QSqlRecord.__ne__ (<i>self</i>, <a href="qsqlrecord.html">QSqlRecord</a> <i>other</i>)</h3><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.12.1 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qt.io">The Qt Company</a> 2015</td><td align="right" width="25%">Qt 4.8.7</td></tr></table></div></address></body></html>
|