Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QSqlRecord Class

TheQSqlRecord class encapsulates a database record.More...

Header:#include <QSqlRecord>
Inherited By:

Q3SqlCursor andQSqlIndex

Public Functions

QSqlRecord()
QSqlRecord(const QSqlRecord & other)
~QSqlRecord()
voidappend(const QSqlField & field)
voidclear()
voidclearValues()
boolcontains(const QString & name) const
intcount() const
QSqlFieldfield(int index) const
QSqlFieldfield(const QString & name) const
QStringfieldName(int index) const
intindexOf(const QString & name) const
voidinsert(int pos, const QSqlField & field)
boolisEmpty() const
boolisGenerated(const QString & name) const
boolisGenerated(int index) const
boolisNull(const QString & name) const
boolisNull(int index) const
voidremove(int pos)
voidreplace(int pos, const QSqlField & field)
voidsetGenerated(const QString & name, bool generated)
voidsetGenerated(int index, bool generated)
voidsetNull(int index)
voidsetNull(const QString & name)
voidsetValue(int index, const QVariant & val)
voidsetValue(const QString & name, const QVariant & val)
QVariantvalue(int index) const
QVariantvalue(const QString & name) const
booloperator!=(const QSqlRecord & other) const
QSqlRecord &operator=(const QSqlRecord & other)
booloperator==(const QSqlRecord & other) const

Detailed Description

TheQSqlRecord class encapsulates a database record.

TheQSqlRecord 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 withsetValue(); if you want to set a field to null usesetNull(). To find the position of a field by name useindexOf(), and to find the name of a field at a particular position usefieldName(). Usefield() to retrieve aQSqlField object for a given field. Usecontains() to see if the record contains a particular field name.

When queries are generated to be executed on the database only those fields for whichisGenerated() is true are included in the generated SQL.

A record can have fields added withappend() orinsert(), replaced withreplace(), and removed withremove(). All the fields can be removed withclear(). The number of fields is given bycount(); all their values can be cleared (to null) usingclearValues().

See alsoQSqlField andQSqlQuery::record().

Member Function Documentation

QSqlRecord::QSqlRecord()

Constructs an empty record.

See alsoisEmpty(),append(), andinsert().

QSqlRecord::QSqlRecord(constQSqlRecord & other)

Constructs a copy ofother.

QSqlRecord isimplicitly shared. This means you can make copies of a record inconstant time.

QSqlRecord::~QSqlRecord()

Destroys the object and frees any allocated resources.

void QSqlRecord::append(constQSqlField & field)

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

See alsoinsert(),replace(), andremove().

void QSqlRecord::clear()

Removes all the record's fields.

See alsoclearValues() andisEmpty().

void QSqlRecord::clearValues()

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

See alsosetValue().

bool QSqlRecord::contains(constQString & name) const

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

int QSqlRecord::count() const

Returns the number of fields in the record.

See alsoisEmpty().

QSqlField QSqlRecord::field(int index) const

Returns the field at positionindex. If theindex is out of range, function returns a default-constructed value.

QSqlField QSqlRecord::field(constQString & name) const

This is an overloaded function.

Returns the field calledname.

QString QSqlRecord::fieldName(int index) const

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

See alsoindexOf().

int QSqlRecord::indexOf(constQString & name) const

Returns the position of the field calledname 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 alsofieldName().

void QSqlRecord::insert(int pos, constQSqlField & field)

Inserts the fieldfield at positionpos in the record.

See alsoappend(),replace(), andremove().

bool QSqlRecord::isEmpty() const

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

See alsoappend(),insert(), andclear().

bool QSqlRecord::isGenerated(constQString & name) const

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

See alsosetGenerated().

bool QSqlRecord::isGenerated(int index) const

This is an overloaded function.

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

See alsosetGenerated().

bool QSqlRecord::isNull(constQString & name) const

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

See alsosetNull().

bool QSqlRecord::isNull(int index) const

This is an overloaded function.

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

void QSqlRecord::remove(int pos)

Removes the field at positionpos. Ifpos is out of range, nothing happens.

See alsoappend(),insert(), andreplace().

void QSqlRecord::replace(int pos, constQSqlField & field)

Replaces the field at positionpos with the givenfield. Ifpos is out of range, nothing happens.

See alsoappend(),insert(), andremove().

void QSqlRecord::setGenerated(constQString & name,bool generated)

Sets the generated flag for the field calledname togenerated. If the field does not exist, nothing happens. Only fields that havegenerated set to true are included in the SQL that is generated byQSqlQueryModel for example.

See alsoisGenerated().

void QSqlRecord::setGenerated(int index,bool generated)

This is an overloaded function.

Sets the generated flag for the fieldindex togenerated.

See alsoisGenerated().

void QSqlRecord::setNull(int index)

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

See alsoisNull() andsetValue().

void QSqlRecord::setNull(constQString & name)

This is an overloaded function.

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

void QSqlRecord::setValue(int index, constQVariant & val)

Sets the value of the field at positionindex toval. If the field does not exist, nothing happens.

See alsovalue() andsetNull().

void QSqlRecord::setValue(constQString & name, constQVariant & val)

This is an overloaded function.

Sets the value of the field calledname toval. If the field does not exist, nothing happens.

QVariant QSqlRecord::value(int index) const

Returns the value of the field located at positionindex in the record. Ifindex is out of bounds, an invalidQVariant is returned.

See alsosetValue(),fieldName(), andisNull().

QVariant QSqlRecord::value(constQString & name) const

This is an overloaded function.

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

See alsoindexOf().

bool QSqlRecord::operator!=(constQSqlRecord & other) const

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

See alsooperator==().

QSqlRecord & QSqlRecord::operator=(constQSqlRecord & other)

Sets the record equal toother.

QSqlRecord isimplicitly shared. This means you can make copies of a record inconstant time.

bool QSqlRecord::operator==(constQSqlRecord & other) const

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

See alsooperator!=().

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp