Qt:Документация 4.3.2/qsqlrecord

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск
40px Внимание: Актуальная версия перевода документации находится здесь

__NOTOC__

Image:qt-logo.png

Главная · Все классы · Основные классы · Классы по группам · Модули · Функции

Image:trolltech-logo.png

Содержание

[править] QSqlRecord Class Reference
[модуль QtSql ]

The QSqlRecord class encapsulates a database record. More...

 #include <QSqlRecord>

Inherited by Q3SqlCursor and QSqlIndex.

[править] Открытые функции


[править] Подробное описание

The QSqlRecord class encapsulates a database record.

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

See also QSqlField and QSqlQuery::record().


[править] Описание функций-членов

[править]
QSqlRecord::QSqlRecord ()

Constructs an empty record.

See also isEmpty(), append(), and insert().

[править]
QSqlRecord::QSqlRecord ( const QSqlRecord & other )

Constructs a copy of other.

QSqlRecord is implicitly shared. This means you can make copies of a record in constant time.

[править]
QSqlRecord::~QSqlRecord ()

Destroys the object and frees any allocated resources.

[править]
void QSqlRecord::append ( const QSqlField & field )

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

See also insert(), replace(), and remove().

[править]
void QSqlRecord::clear ()

Removes all the record's fields.

See also clearValues() and isEmpty().

[править]
void QSqlRecord::clearValues ()

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

See also setValue().

[править]
bool QSqlRecord::contains ( const QString & name ) const

Returns true if there is a field in the record called name; otherwise returns false.

[править]
int QSqlRecord::count () const

Returns the number of fields in the record.

See also isEmpty().

[править]
QSqlField QSqlRecord::field ( int index ) const

Returns the field at position index. If the position is out of range, an empty field is returned.

[править]
QSqlField QSqlRecord::field ( const QString & name ) const

This is an overloaded member function, provided for convenience.

Returns the field called name.

[править]
QString QSqlRecord::fieldName ( int index ) const

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

See also indexOf().

[править]
int QSqlRecord::indexOf ( const QString & name ) const

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.

See also fieldName().

[править]
void QSqlRecord::insert ( int pos, const QSqlField & field )

Inserts the field field at position pos in the record.

See also append(), replace(), and remove().

[править]
bool QSqlRecord::isEmpty () const

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

See also append(), insert(), and clear().

[править]
bool QSqlRecord::isGenerated ( const QString & name ) const

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

See also setGenerated().

[править]
bool QSqlRecord::isGenerated ( int index ) const

This is an overloaded member function, provided for convenience.

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

See also setGenerated().

[править]
bool QSqlRecord::isNull ( const QString & name ) const

Returns true if the field called name is null or if there is no field called name; otherwise returns false.

See also setNull().

[править]
bool QSqlRecord::isNull ( int index ) const

This is an overloaded member function, provided for convenience.

Returns true if the field index is null or if there is no field at position index; otherwise returns false.

[править]
void QSqlRecord::remove ( int pos )

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

See also append(), insert(), and replace().

[править]
void QSqlRecord::replace ( int pos, const QSqlField & field )

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

See also append(), insert(), and remove().

[править]
void QSqlRecord::setGenerated ( const 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 for example.

See also isGenerated().

[править]
void QSqlRecord::setGenerated ( int index, bool generated )

This is an overloaded member function, provided for convenience.

Sets the generated flag for the field index to generated.

See also isGenerated().

[править]
void QSqlRecord::setNull ( int index )

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

See also isNull() and setValue().

[править]
void QSqlRecord::setNull ( const QString & name )

This is an overloaded member function, provided for convenience.

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

[править]
void QSqlRecord::setValue ( int index, const QVariant & val )

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

See also value() and setNull().

[править]
void QSqlRecord::setValue ( const QString & name, const QVariant & val )

This is an overloaded member function, provided for convenience.

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

[править]
QVariant QSqlRecord::value ( int index ) const

Returns the value of the field located at position index in the record. If index is out of bounds, an invalid QVariant is returned.

See also setValue(), fieldName(), and isNull().

[править]
QVariant QSqlRecord::value ( const QString & name ) const

This is an overloaded member function, provided for convenience.

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

See also indexOf().

[править]
bool QSqlRecord::operator!= ( const QSqlRecord & other ) const

Returns true if this object is not identical to other; otherwise returns false.

See also operator==().

[править]
QSqlRecord & QSqlRecord::operator= ( const QSqlRecord & other )

Sets the record equal to other.

QSqlRecord is implicitly shared. This means you can make copies of a record in constant time.

[править]
bool QSqlRecord::operator== ( const QSqlRecord & other ) const

Returns true if this object is identical to other (i.e., has the same fields in the same order); otherwise returns false.

See also operator!=().


Copyright © 2007 Trolltech Trademarks
Qt 4.3.2