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  · 

QtopiaSql Class Reference
[QtBaseModule]

The QtopiaSql class provides a collection of methods for setting up and managing database connections. More...

    #include <QtopiaSql>

Public Functions

Static Public Members


Detailed Description

The QtopiaSql class provides a collection of methods for setting up and managing database connections.

Qt Extended has a database architecture which uses a number of different databases, including a seperate database for each removable storage media. Additionally the database schema required for a particular version of Qt Extended may differ from that currently on the device due to Qt Extended being upgraded.

Use these routines to manage connections to these databases. The QtopiaDatabaseId type identifies a particular database of the collectin.

The systemDatabase() method is used to fetch a QSqlDatabase object pointing to the Qt Extended main system database. Call attachDB() to connect a database for a particular path, typically associated with a new storage media mount-point. These will be operated on with the system database as a unit.

Lists of the current databases can be obtained with databaseIds() and databases(). Given a database id obtain the path for the associated media mount point with databasePathForId() and obtain the QSqlDatabase itself with database().

The ensureTableExists() methods call through to the Database migration utility to ensure the table schema referred to is loaded.

The attachDB() methods use the underlying database implementation specific method for creating queries across seperate databases. In SQLITE this method is the ATTACH statement, but an equivalent method is used for other implementations.

This documentation should be read and understood in conjunction with the Database Policy and the Database Specification


Member Function Documentation

QSqlDatabase QtopiaSql::applicationSpecificDatabase ( const QString & appname )

Return a QSqlDatabase object for the database specific to the application given by appname Note: You are responsible for calling QSqlDatabase::removeDatabase once you are finished with the connection.

void QtopiaSql::attachDB ( const QString & path )

Attach the database for the media located at the mount-point path. The database to use is located on that media.

After this call database entries for the attached database will be used in future queries executed.

See also exec().

void QtopiaSql::attachDB ( const QString & path, const QString & dbPath )

This is an overloaded member function, provided for convenience.

Attach the database for the media located at the mount-point path. The path given by dbPath is the database to use in the attach.

See also exec().

QSqlDatabase & QtopiaSql::database ( const QtopiaDatabaseId & id )

Returns a reference to the qtopia database object (used for settings storage, doc manager, etc) for the given QtopiaDatabaseId id. There is a separate set of database objects created per thread.

QtopiaDatabaseId QtopiaSql::databaseIdForDatabasePath ( const QString & dbPath )

Return the QtopiaDatabaseId identifier for the database located at the given dbPath.

Internally causes the database system to be opened, if not already open.

QtopiaDatabaseId QtopiaSql::databaseIdForPath ( const QString & path )

Return the QtopiaDatabaseId identifier for the database associated with the given path.

Internally causes the database system to be opened, if not already open.

const QList<QtopiaDatabaseId> QtopiaSql::databaseIds ()

Return a list of the QtopiaDatabaseId entries for all the attached databases.

Internally causes the database system to be opened, if not already open.

QString QtopiaSql::databasePathForId ( const QtopiaDatabaseId & id )

Return the full path to the mount-point related to the database for the given QtopiaDatabaseId id

const QList<QSqlDatabase> QtopiaSql::databases ()

Returns a list QSqlDatabase objects comprising all attached databases.

void QtopiaSql::detachDB ( const QString & path )

Undo the effect of the attachDB() method, for the database associated with mount-point path.

After this call database queries executed will not attempt to reference this database.

See also attachDB() and exec().

bool QtopiaSql::ensureTableExists ( const QString & tableName, QSqlDatabase & db )

Ensure that the given table tableName exists in the database db

Return true if the operation was successful; otherwise returns false

bool QtopiaSql::ensureTableExists ( const QStringList & tableNames, QSqlDatabase & db )

This is an overloaded member function, provided for convenience.

Ensure that all tables in the list of tableNames exists in the database db.

Internally this invokes the "DBMigrationEngine" service to run any migrations or schema updates required.

QString QtopiaSql::escape ( const QString & input )   [static]

Returns the given input with all single quote characters repalced with two consecutive quote characters.

QString QtopiaSql::escapeString ( const QString & input )

This function is deprecated.

Returns the given input with all single quote characters repalced with two consecutive quote characters.

QSqlError QtopiaSql::exec ( const QString & query, QSqlDatabase & db, bool inTransaction = true )

Execute the given QString query on the database db. If inTransaction is true, then perform the query inside an SQL transaction, for atomicity, if the database backend supports this.

QSqlError QtopiaSql::exec ( QSqlQuery & query, QSqlDatabase & db, bool inTransaction = true )

This is an overloaded member function, provided for convenience.

Execute the given QSqlQuery query on the database db. If inTransaction is true, then perform the query inside an SQL transaction, for atomicity, if the database backend supports this.

QtopiaSql * QtopiaSql::instance ()   [static]

Returns a pointer to the singleton object of QtopiaSql. This is the preferred method of accessing the QtopiaSql class.

bool QtopiaSql::isDatabase ( const QString & path )

Return true if the file located at the given path is a Qt Extended database file, for example the datastore used by the SQLITE engine; return false otherwise.

This may be used to test if the file should be shown to the end-user.

    if ( !QtopiaSql::isDatabase( fileFound ))
        listForDisplay.append( fileFound );

bool QtopiaSql::isValidDatabaseId ( const QtopiaDatabaseId & id )

Returns true if the database id is a valid open database in the system.

void QtopiaSql::loadConfig ( const QString & type, const QString & name, const QString & user )

Initializes the state of the QtopiaSql system with the type of database, eg "sqlite".

The meaning of the name and user parameters are as defined in QSqlDatabase.

void QtopiaSql::logQuery ( const QSqlQuery & q )

Send a string for the given QSqlQuery q to the qtopia logging system.

void QtopiaSql::openDatabase ()

Opens the main system database, if it is not already open.

int QtopiaSql::stringCompare ( const QString & l, const QString & r )   [static]

Perform a locale aware string compare of the two argument QStrings l and r using the database implementations native collating functions.

If the database does not provide one, or if one is provided but not integrated, then returns the same result as QString::localeAwareCompare()

QSqlDatabase & QtopiaSql::systemDatabase ()

Return the QSqlDatabase instance of the main system database.

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 64
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le Qt Developer Network au hasard

Logo

Les composants

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 qtextended4.4
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