![]() |
CopperSpice API
1.9.2
|
The QSqlRecord class encapsulates a database record. More...
Public Methods | |
QSqlRecord () | |
QSqlRecord (const QSqlRecord &other) | |
~QSqlRecord () | |
void | append (const QSqlField &field) |
void | clear () |
void | clearValues () |
bool | contains (const QString &name) const |
int | count () const |
QSqlField | field (const QString &name) const |
QSqlField | field (int index) 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 |
bool | operator!= (const QSqlRecord &other) const |
QSqlRecord & | operator= (const QSqlRecord &other) |
bool | operator== (const QSqlRecord &other) 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 (const QString &name) |
void | setNull (int index) |
void | setValue (const QString &name, const QVariant &val) |
void | setValue (int index, const QVariant &val) |
QVariant | value (const QString &name) const |
QVariant | value (int index) const |
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 field 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().
QSqlRecord::QSqlRecord | ( | const QSqlRecord & | other | ) |
Constructs a copy of other.
QSqlRecord::~QSqlRecord | ( | ) |
Destroys the object and frees any allocated resources.
void QSqlRecord::append | ( | const QSqlField & | field | ) |
void QSqlRecord::clear | ( | ) |
Removes all the record's fields.
void QSqlRecord::clearValues | ( | ) |
Clears the value of all fields in the record and sets each field to null.
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.
QSqlField QSqlRecord::field | ( | int | index | ) | const |
Returns the field at position index. If the index is out of range a default constructed object of type QSqlField is returned. Refer to default constructed elements for additional information.
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.
int QSqlRecord::indexOf | ( | const QString & | name | ) | const |
Returns the position of the field called name within the record, or -1 if it can not be found. Field names are not case sensitive. If more than one field matches the first one is returned.
void QSqlRecord::insert | ( | int | pos, |
const QSqlField & | field | ||
) |
bool QSqlRecord::isEmpty | ( | ) | const |
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.
bool QSqlRecord::isGenerated | ( | int | index | ) | const |
Returns true if the record has a field at position index and this field is to be generated (the default), otherwise returns false.
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.
bool QSqlRecord::isNull | ( | int | index | ) | const |
Returns true if the field index is null or if there is no field at position index, otherwise returns false.
|
inline |
Returns true if this object is not identical to other, otherwise returns false.
QSqlRecord & QSqlRecord::operator= | ( | const QSqlRecord & | other | ) |
Copy assigns from other and returns a reference to this object.
bool QSqlRecord::operator== | ( | const QSqlRecord & | other | ) | const |
Returns true if this object is identical to other, otherwise returns false.
void QSqlRecord::remove | ( | int | pos | ) |
void QSqlRecord::replace | ( | int | pos, |
const QSqlField & | field | ||
) |
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.
void QSqlRecord::setGenerated | ( | int | index, |
bool | generated | ||
) |
Sets the generated flag for the field index to generated.
void QSqlRecord::setNull | ( | const QString & | name | ) |
Sets the value of the field called name to null. If the field does not exist, nothing happens.
void QSqlRecord::setNull | ( | int | index | ) |
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 val. If the field does not exist, nothing happens.
void QSqlRecord::setValue | ( | int | index, |
const QVariant & | val | ||
) |
Returns the value of the field called name in the record. If field name does not exist an invalid variant is returned.
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.