QSqlRecord 類封裝數據庫記錄。 更多...
| 頭: | #include <QSqlRecord> |
| qmake: | QT += sql |
| 繼承者: |
| QSqlRecord (const QSqlRecord & other ) | |
| QSqlRecord () | |
| QSqlRecord & | operator= (const QSqlRecord & other ) |
| ~QSqlRecord () | |
| void | append (const QSqlField & field ) |
| void | clear () |
| void | clearValues () |
| bool | contains (const QString & name ) const |
| int | count () const |
| QSqlField | field (int index ) const |
| QSqlField | field (const QString & name ) const |
| QString | fieldName (int index ) const |
| int | indexOf (const QString & name ) const |
| void | insert (int pos , const QSqlField & field ) |
| bool | isEmpty () const |
| bool | isGenerated (const QString & name ) const |
| bool | isGenerated (int index ) const |
| bool | isNull (const QString & name ) const |
| bool | isNull (int index ) const |
| QSqlRecord | keyValues (const QSqlRecord & keyFields ) const |
| void | remove (int pos ) |
| void | replace (int pos , const QSqlField & field ) |
| void | setGenerated (const QString & name , bool generated ) |
| void | setGenerated (int index , bool generated ) |
| void | setNull (int index ) |
| void | setNull (const QString & name ) |
| void | setValue (int index , const QVariant & val ) |
| void | setValue (const QString & name , const QVariant & val ) |
| QVariant | value (int index ) const |
| QVariant | value (const QString & name ) const |
| bool | operator!= (const QSqlRecord & other ) const |
| bool | operator== (const QSqlRecord & other ) const |
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.
The values of a record's fields can be set by name or position with setValue (); if you want to set a field to null use setNull (). To find the position of a field by name use indexOf (), and to find the name of a field at a particular position use fieldName ()。使用 field () to retrieve a QSqlField object for a given field. Use contains () to see if the record contains a particular field name.
When queries are generated to be executed on the database only those fields for which isGenerated () is true are included in the generated SQL.
A record can have fields added with append () 或 insert (), replaced with replace (), and removed with remove (). All the fields can be removed with clear (). The number of fields is given by count (); all their values can be cleared (to null) using clearValues ().
另請參閱 QSqlField and QSqlQuery::record ().
構造副本為 other .
QSqlRecord is 隱式共享 . This means you can make copies of a record in 常量時間 .
Constructs an empty record.
另請參閱 isEmpty (), append (),和 insert ().
Sets the record equal to other .
QSqlRecord is 隱式共享 . This means you can make copies of a record in 常量時間 .
銷毀對象並釋放任何分配資源。
Append a copy of field field to the end of the record.
另請參閱 insert (), replace (),和 remove ().
Removes all the record's fields.
另請參閱 clearValues () 和 isEmpty ().
Clears the value of all fields in the record and sets each field to null.
另請參閱 setValue ().
返迴
true
if there is a field in the record called
name
;否則返迴
false
.
Returns the number of fields in the record.
另請參閱 isEmpty ().
Returns the field at position index 。若 index is out of range, function returns a 默認構造值 .
這是重載函數。
Returns the field called name .
Returns the name of the field at position index . If the field does not exist, an empty string is returned.
另請參閱 indexOf ().
Returns the position of the field called name 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.
另請參閱 fieldName ().
Inserts the field field 在位置 pos in the record.
另請參閱 append (), replace (),和 remove ().
返迴
true
if there are no fields in the record; otherwise returns
false
.
另請參閱 append (), insert (),和 clear ().
返迴
true
if the record has a field called
name
and this field is to be generated (the default); otherwise returns
false
.
另請參閱 setGenerated ().
這是重載函數。
返迴
true
if the record has a field at position
index
and this field is to be generated (the default); otherwise returns
false
.
另請參閱 setGenerated ().
返迴
true
if the field called
name
is null or if there is no field called
name
;否則返迴
false
.
另請參閱 setNull ().
這是重載函數。
返迴
true
if the field
index
is null or if there is no field at position
index
;否則返迴
false
.
Returns a record containing the fields represented in keyFields set to values that match by field name.
該函數在 Qt 5.1 引入。
Removes the field at position pos 。若 pos is out of range, nothing happens.
另請參閱 append (), insert (),和 replace ().
Replaces the field at position pos 采用給定 field 。若 pos is out of range, nothing happens.
另請參閱 append (), insert (),和 remove ().
Sets the generated flag for the field called name to generated . If the field does not exist, nothing happens. Only fields that have generated set to true are included in the SQL that is generated by QSqlQueryModel 例如。
另請參閱 isGenerated ().
這是重載函數。
Sets the generated flag for the field index to generated .
另請參閱 isGenerated ().
Sets the value of field index to null. If the field does not exist, nothing happens.
這是重載函數。
Sets the value of the field called name to null. If the field does not exist, nothing happens.
Sets the value of the field at position index to val . If the field does not exist, nothing happens.
這是重載函數。
Sets the value of the field called name to val . If the field does not exist, nothing happens.
Returns the value of the field located at position index in the record. If index is out of bounds, an invalid QVariant 被返迴。
另請參閱 setValue (), fieldName (),和 isNull ().
這是重載函數。
Returns the value of the field called name in the record. If field name does not exist an invalid variant is returned.
另請參閱 indexOf ().
返迴
true
if this object is not identical to
other
;否則返迴
false
.
另請參閱 operator== ().
返迴
true
if this object is identical to
other
(i.e., has the same fields in the same order); otherwise returns
false
.
另請參閱 operator!= ().