Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QSqlRecord Class Reference
[QtSql module]

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

 #include <QSqlRecord>

Inherited by Q3SqlCursor and QSqlIndex.

Public Functions


Detailed Description

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


Member Function Documentation

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 function.

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 function.

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 function.

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 function.

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 function.

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 function.

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 function.

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

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 103
  2. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 56
  3. «Le projet de loi des droits du développeur» : quelles conditions doivent remplir les entreprises pour que le développeur puisse réussir ? 90
  4. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 31
  5. Qt Commercial : Digia organise un webinar gratuit le 27 mars sur la conception d'interfaces utilisateur et d'applications avec le framework 0
  6. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  7. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 11
Page suivante
  1. Linus Torvalds : le "C++ est un langage horrible", en justifiant le choix du C pour le système de gestion de version Git 100
  2. Comment prendre en compte l'utilisateur dans vos applications ? Pour un développeur, « 90 % des utilisateurs sont des idiots » 231
  3. Quel est LE livre que tout développeur doit lire absolument ? Celui qui vous a le plus marqué et inspiré 96
  4. Apple cède et s'engage à payer des droits à Nokia, le conflit des brevets entre les deux firmes s'achève 158
  5. Nokia porte à nouveau plainte contre Apple pour violation de sept nouveaux brevets 158
  6. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 103
  7. Quel est le code dont vous êtes le plus fier ? Pourquoi l'avez-vous écrit ? Et pourquoi vous a-t-il donné autant de satisfaction ? 83
Page suivante

Le Qt Developer Network au hasard

Logo

Comment fermer une application

Le Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.5
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web