QSqlRecord Class Reference

[ QtSql module]

QSqlRecord 类封装数据库记录。 更多...

Inherited by QSqlIndex .

方法

Special Methods


详细描述

QSqlRecord 类封装数据库记录。

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 ()。 number of fields is given by count (); all their values can be cleared (to null) using clearValues ().


方法文档编制

QSqlRecord.__init__ ( self )

Constructs an empty record.

另请参阅 isEmpty (), append (),和 insert ().

QSqlRecord.__init__ ( self , QSqlRecord   other )

构造副本为 other .

QSqlRecord is 隐式共享 . This means you can make copies of a record in constant time .

QSqlRecord.append ( self , QSqlField   field )

Append a copy of field field to the end of the record.

另请参阅 insert (), replace (),和 remove ().

QSqlRecord.clear ( self )

Removes all the record's fields.

另请参阅 clearValues () 和 isEmpty ().

QSqlRecord.clearValues ( self )

Clears the value of all fields in the record and sets each field to null.

另请参阅 setValue ().

bool QSqlRecord.contains ( self , QString  name )

Returns true if there is a field in the record called name ;否则返回 false。

int QSqlRecord.count ( self )

Returns the number of fields in the record.

另请参阅 isEmpty ().

QSqlField QSqlRecord.field ( self , int  i )

Returns the field at position index 。若 index is out of range, function returns a default-constructed value .

QSqlField QSqlRecord.field ( self , QString  name )

这是重载函数。

Returns the field called name .

QString QSqlRecord.fieldName ( self , int  i )

Returns the name of the field at position index 。若 field does not exist, an empty string is returned.

另请参阅 indexOf ().

int QSqlRecord.indexOf ( self , QString  name )

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 ().

QSqlRecord.insert ( self , int  pos , QSqlField   field )

Inserts the field field 在位置 pos 在 record.

另请参阅 append (), replace (),和 remove ().

bool QSqlRecord.isEmpty ( self )

Returns true if there are no fields in the record; otherwise returns false.

另请参阅 append (), insert (),和 clear ().

bool QSqlRecord.isGenerated ( self , int  i )

Returns true if the record has a field called name and this field is to be generated (the default); otherwise returns false.

另请参阅 setGenerated ().

bool QSqlRecord.isGenerated ( self , QString  name )

这是重载函数。

Returns true if the record has a field at position index and this field is to be generated (the default); otherwise returns false.

另请参阅 setGenerated ().

bool QSqlRecord.isNull ( self , int  i )

Returns true if the field called name is null or if there is no field called name ;否则返回 false。

另请参阅 setNull ().

bool QSqlRecord.isNull ( self , QString  name )

这是重载函数。

Returns true if the field index is null or if there is no field at position index ;否则返回 false。

QSqlRecord.remove ( self , int  pos )

Removes the field at position pos 。若 pos is out of range, nothing happens.

另请参阅 append (), insert (),和 replace ().

QSqlRecord.replace ( self , int  pos , QSqlField   field )

Replaces the field at position pos with the given field 。若 pos is out of range, nothing happens.

另请参阅 append (), insert (),和 remove ().

QSqlRecord.setGenerated ( self , QString  name , bool  generated )

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 ().

QSqlRecord.setGenerated ( self , int  i , bool  generated )

这是重载函数。

Sets the generated flag for the field index to generated .

另请参阅 isGenerated ().

QSqlRecord.setNull ( self , int  i )

Sets the value of field index to null. If the field does not exist, nothing happens.

另请参阅 isNull () and setValue ().

QSqlRecord.setNull ( self , QString  name )

这是重载函数。

Sets the value of the field called name to null. If the field does not exist, nothing happens.

QSqlRecord.setValue ( self , int  i , QVariant  val )

Sets the value of the field at position index to val . If the field does not exist, nothing happens.

另请参阅 value () 和 setNull ().

QSqlRecord.setValue ( self , QString  name , QVariant  val )

这是重载函数。

Sets the value of the field called name to val 。若 the field does not exist, nothing happens.

QVariant QSqlRecord.value ( self , int  i )

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 ().

QVariant QSqlRecord.value ( self , QString  name )

这是重载函数。

Returns the value of the field called name in the record. If field name does not exist an invalid variant is returned.

另请参阅 indexOf ().

bool QSqlRecord.__eq__ ( self , QSqlRecord   other )

QSqlRecord.__len__ ( self )

bool QSqlRecord.__ne__ ( self , QSqlRecord   other )