|
TreeFrogFramework 2.10
|
#include <tsqlquery.h>


Public Member Functions | |
| TSqlQuery (int databaseId=0) | |
| TSqlQuery (const QSqlDatabase &db) | |
| TSqlQuery & | prepare (const QString &query) |
| bool | load (const QString &filename) |
| bool | loadPreparedQuery (const QString &filename) |
| TSqlQuery & | bind (const QString &placeholder, const QVariant &val) |
| TSqlQuery & | bind (int pos, const QVariant &val) |
| TSqlQuery & | addBind (const QVariant &val) |
| QVariant | boundValue (int pos) const |
| QVariantList | boundValues () const |
| QVariant | getNextValue () |
| QString | queryDirPath () const |
| bool | exec (const QString &query) |
| bool | exec () |
| int | numRowsAffected () const |
| int | size () const |
| bool | next () |
| QVariant | value (int index) const |
| QVariant | value (const QString &name) const |
Static Public Member Functions | |
| static void | clearCachedQueries () |
| static QString | escapeIdentifier (const QString &identifier, QSqlDriver::IdentifierType type=QSqlDriver::FieldName, int databaseId=0) |
| static QString | escapeIdentifier (const QString &identifier, QSqlDriver::IdentifierType type, const QSqlDriver *driver) |
| static QString | formatValue (const QVariant &val, const QMetaType &type, int databaseId=0) |
| static QString | formatValue (const QVariant &val, const QMetaType &type, const QSqlDatabase &database) |
| static QString | formatValue (const QVariant &val, const QMetaType &type, const QSqlDriver *driver) |
| static QString | formatValue (const QVariant &val, const QSqlDriver *driver) |
| static QString | formatValue (const QVariant &val, const QSqlDatabase &database) |
The TSqlQuery class provides a means of executing and manipulating SQL statements.
| TSqlQuery::TSqlQuery | ( | int | databaseId = 0 | ) |
Constructs a TSqlQuery object using the database databaseId.
| TSqlQuery::TSqlQuery | ( | const QSqlDatabase & | db | ) |
| TSqlQuery & TSqlQuery::addBind | ( | const QVariant & | val | ) |
Adds the value val to the list of values when using positional value binding and returns the query object.
The order of the addBind() calls determines which placeholder a value will be bound to in the prepared query.
| TSqlQuery & TSqlQuery::bind | ( | const QString & | placeholder, |
| const QVariant & | val | ||
| ) |
Set the placeholder placeholder to be bound to value val in the prepared statement.
| TSqlQuery & TSqlQuery::bind | ( | int | pos, |
| const QVariant & | val | ||
| ) |
Set the placeholder in position pos to be bound to value val in the prepared statement.
Field numbering starts at 0.
| QVariant TSqlQuery::boundValue | ( | int | pos | ) | const |
| QVariantList TSqlQuery::boundValues | ( | ) | const |
|
static |
Clears currently cached SQL queries that are loaded by the load() function.
|
static |
Returns the identifier escaped according to the rules of the driver driver.
The identifier can either be a table name or field name, dependent on type.
|
static |
Returns the identifier escaped according to the rules of the database databaseId.
The identifier can either be a table name or field name, dependent on type.
| bool TSqlQuery::exec | ( | ) |
Executes a previously prepared SQL query.
Returns true if the query executed successfully; otherwise returns false.
| bool TSqlQuery::exec | ( | const QString & | query | ) |
Executes the SQL in query.
Returns true and sets the query state to active if the query was successful; otherwise returns false.
|
static |
|
static |
Returns a string representation of the value val for the database database.
|
static |
Returns a string representation of the value val for the database databaseId.
|
inlinestatic |
|
static |
Returns a string representation of the value val for the database database.
|
inline |
Returns the value of first field in the next object and advances the internal iterator by one position.
It can be used for a query returning at least one result, such as 'SELECT COUNT(*)'.
| bool TSqlQuery::load | ( | const QString & | filename | ) |
Loads a query from the given file filename.
|
inline |
|
inline |
Retrieves the next record in the result, if available, and positions the query on the retrieved record.
Note that the result must be in the active state and isSelect() must return true before calling this function or it will do nothing and return false.
|
inline |
Returns the number of rows affected by the result's SQL statement, or -1 if it cannot be determined.
Note that for SELECT statements, the value is undefined; use size() instead. If the query is not active, -1 is returned.
| TSqlQuery & TSqlQuery::prepare | ( | const QString & | query | ) |
Prepares the SQL query query for execution.
| QString TSqlQuery::queryDirPath | ( | ) | const |
Returns the directory path for SQL query files, which is indicated by the value for application setting SqlQueriesStoredDirectory.
|
inline |
Returns the size of the result (number of rows returned), or -1 if the size cannot be determined or if the database does not support reporting information about query sizes.
Note that for non-SELECT statements (isSelect() returns false), size() will return -1. If the query is not active (isActive() returns false), -1 is returned. To determine the number of rows affected by a non-SELECT statement, use numRowsAffected().
|
inline |
Returns the value of the field called name in the current record.
If field name does not exist an invalid variant is returned.
|
inline |
Returns the value of field index in the current record.