EasyQtSql
Easy SQL data access helper for QtSql
|
QSqlQuery wrapper with handy data fetch methods. More...
#include <EasyQtSql.h>
Public Member Functions | |
QSqlQuery & | unwrappedQuery () |
Returns reference on wrapped QSqlQuery. More... | |
bool | next () |
Retrieves the next record in the result, if available, and positions the query on the retrieved record. More... | |
bool | previous () |
Retrieves the previous record in the result, if available, and positions the query on the retrieved record. More... | |
bool | nextResult () |
Discards the current result set and navigates to the next if available (if database is capable of returning multiple result sets) More... | |
bool | first () |
Retrieves the first record in the result, if available, and positions the query on the retrieved record. More... | |
bool | last () |
Retrieves the last record in the result, if available, and positions the query on the retrieved record. More... | |
bool | seek (int index, bool relative=false) |
Retrieves the record at position index, if available, and positions the query on the retrieved record. More... | |
int | at () const |
Returns the current internal position of the query. The first record is at position zero. More... | |
bool | isActive () const |
Returns true if the query is active. An active QSqlQuery is one that has been exec()'d successfully but not yet finished with. More... | |
bool | isValid () const |
Returns true if the query is currently positioned on a valid record; otherwise returns false. More... | |
bool | isForwardOnly () const |
Returns true if you can only scroll forward through a result set; otherwise returns false. More... | |
int | size () const |
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. More... | |
int | numRowsAffected () const |
Returns the number of rows affected by the result's SQL statement, or -1 if it cannot be determined. More... | |
QSqlError | lastError () const |
Returns error information about the last error (if any) that occurred with this query. More... | |
QString | lastQuery () const |
Returns the text of the current query being used, or an empty string if there is no current query text. More... | |
QString | executedQuery () const |
Returns the last query that was successfully executed. More... | |
QVariant | value (int column) const |
Returns the value of field index in the current record. More... | |
QVariant | value (const QString &colName) const |
Returns the value of the field called name in the current record. If field name does not exist an invalid variant is returned. More... | |
QVariant | boundValue (int column) const |
Returns the value for the placeholder at position column. More... | |
QVariant | boundValue (const QString &aliasName) const |
Returns the value for the placeholder with aliasName. More... | |
QVariantList | boundValues () const |
Returns list of the bound values (with positional binding) More... | |
QVariantMap | toMap () const |
Returns QVariantMap filled with values fetched from current result row. Key is QString (result column name) and value is QVariant value. More... | |
QVariantList | toList () const |
Returns QVariantList filled with values fetched from current result row. More... | |
QStringList | toStringList () const |
Returns QStringList filled with values fetched from current result row. SQL values converted to QString with QVariant::toString() method. More... | |
QVector< QVariant > | toVector () const |
Returns QVector<QVariant> filled with values fetched from current result row. SQL values not converted: QSqlQuery::value() return value used. More... | |
template<typename T > | |
QVector< T > | toVector (bool skipNullValues=false) const |
Returns QVector<T> filled with values fetched from current result row. SQL values converted with QVariant::value<T>(). QVector::canConvert<T>() method used for convertability check. Non-convertable values skipped. More... | |
QVector< int > | parseToIntVector (int base=10, bool skipNullValues=false) const |
Returns vector of (optionally parsed) integer values from currently active result row. More... | |
template<typename T > | |
T | scalar () const |
Returns scalar value converted to type T (the value of the first column of the current row) More... | |
QVariant | scalar () const |
Returns scalar value (the value of the first column of the current row) More... | |
void | fetchVars (int &value) const |
Assigns a variable the value from the current record. More... | |
void | fetchVars (double &value) const |
Assigns a variable the value from the current record. More... | |
void | fetchVars (QString &value) const |
Assigns a variable the value from the current record. More... | |
void | fetchVars (bool &value) const |
Assigns a variable the value from the current record. More... | |
void | fetchVars (QDate &value) const |
Assigns a variable the value from the current record. More... | |
void | fetchVars (QDateTime &value) const |
Assigns a variable the value from the current record. More... | |
void | fetchVars (QTime &value) const |
Assigns a variable the value from the current record. More... | |
void | fetchVars (QByteArray &value) const |
Assigns a variable the value from the current record. More... | |
void | fetchVars (QVariant &value) const |
Assigns a variable the value from the current record. More... | |
template<typename... Rest> | |
void | fetchVars (int &value, Rest &... rest) const |
template<typename... Rest> | |
void | fetchVars (double &value, Rest &... rest) const |
template<typename... Rest> | |
void | fetchVars (QString &value, Rest &... rest) const |
template<typename... Rest> | |
void | fetchVars (bool &value, Rest &... rest) const |
template<typename... Rest> | |
void | fetchVars (QDate &value, Rest &... rest) const |
template<typename... Rest> | |
void | fetchVars (QDateTime &value, Rest &... rest) const |
template<typename... Rest> | |
void | fetchVars (QTime &value, Rest &... rest) const |
template<typename... Rest> | |
void | fetchVars (QByteArray &value, Rest &... rest) const |
template<typename... Rest> | |
void | fetchVars (QVariant &value, Rest &... rest) const |
void | fetchObject (QObject &object) const |
Fills Q_OBJECT object properties with data fetched from current result row. More... | |
template<typename T > | |
void | fetchGadget (T &gadget) const |
Fills Q_GADGET object properties with data fetched from current result row. More... | |
void | fetchMap (QVariantMap &map) const |
Fills QVariantMap with values fetched from current result row. Key is QString (result column name) and value is QVariant value. More... | |
void | fetchList (QVariantList &list) const |
Fills QVariantList with values fetched from current result row. SQL values not converted: QSqlQuery::value() return value used. More... | |
void | fetchVector (QVector< QVariant > &vector) const |
Fills QVector<QVariant> with values fetched from current result row. SQL values not converted: QSqlQuery::value() return value used. More... | |
void | fetchStringList (QStringList &list) const |
Fills QStringList with values fetched from current result row. SQL values converted to QString with QVariant::toString() method. More... | |
Friends | |
class | Database |
class | Transaction |
class | PreparedQuery |
QSqlQuery wrapper with handy data fetch methods.
|
inline |
Returns the current internal position of the query. The first record is at position zero.
Wrapper over QSqlQuery::at()
|
inline |
Returns the value for the placeholder at position column.
Wrapper over QSqlQuery::boundValue()
|
inline |
Returns the value for the placeholder with aliasName.
Use subclasses of ParamDirectionWrapper class (In, Out, InOut) for aliased/directional parameter binding during PreparedQuery::exec execution
Use Out and InOut wrappers if you need to read Stored Procedures return values (output parameters).
|
inline |
Returns list of the bound values (with positional binding)
Wrapper over QSqlQuery::boundValues()
|
inline |
Returns the last query that was successfully executed.
Wrapper over QSqlQuery::executedQuery()
|
inline |
Fills Q_GADGET object properties with data fetched from current result row.
Qt Meta-Object System used. Only writable properties can be filled.
C++ struct fields will be mapped on SQL result table by Q_PROPERTY member names. For example, if Q_GADGET struct contains Q_PROPERTY named "e" but SELECT query defines no "e" column, object property "e" not affected by the method.
gadget | Q_GADGET reference |
|
inline |
Fills QVariantList with values fetched from current result row. SQL values not converted: QSqlQuery::value() return value used.
[out] | list | QVariantList |
|
inline |
Fills QVariantMap with values fetched from current result row. Key is QString (result column name) and value is QVariant value.
[out] | map | QVariantMap |
|
inline |
Fills Q_OBJECT object properties with data fetched from current result row.
Qt Meta-Object System used. Only writable properties can be filled.
C++ class fields (properties) will be mapped on SQL result table by Q_PROPERTY member names. For example, if Q_OBJECT class contains Q_PROPERTY named "e" but SELECT query defines no "e" column, object property "e" not affected by the method.
object | Q_OBJECT object reference |
|
inline |
Fills QStringList with values fetched from current result row. SQL values converted to QString with QVariant::toString() method.
[out] | list | QStringList |
|
inline |
Assigns a variable the value from the current record.
The method has a variable number of parameters, which allows filling the list of variables with values from the current record in single call.
Overloaded EasyQtSql::fetchVars methods performs the corresponding type conversion with QVariant::to*() methods.
Supported parameter types: int, double, bool, QString, QDate, QDateTime, QTime, QByteArray, QVariant.
Variables of different types can be mixed.
|
inline |
Assigns a variable the value from the current record.
|
inline |
Assigns a variable the value from the current record.
|
inline |
Assigns a variable the value from the current record.
|
inline |
Assigns a variable the value from the current record.
|
inline |
Assigns a variable the value from the current record.
|
inline |
Assigns a variable the value from the current record.
|
inline |
Assigns a variable the value from the current record.
|
inline |
Assigns a variable the value from the current record.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Fills QVector<QVariant> with values fetched from current result row. SQL values not converted: QSqlQuery::value() return value used.
[out] | vector | QVector<QVariant> |
|
inline |
Retrieves the first record in the result, if available, and positions the query on the retrieved record.
Wrapper over QSqlQuery::first()
|
inline |
Returns true if the query is active. An active QSqlQuery is one that has been exec()'d successfully but not yet finished with.
Wrapper over QSqlQuery::isActive()
|
inline |
Returns true if you can only scroll forward through a result set; otherwise returns false.
Wrapper over QSqlQuery::isForwardOnly()
|
inline |
Returns true if the query is currently positioned on a valid record; otherwise returns false.
Wrapper over QSqlQuery::isValid()
|
inline |
Retrieves the last record in the result, if available, and positions the query on the retrieved record.
Wrapper over QSqlQuery::last()
|
inline |
Returns error information about the last error (if any) that occurred with this query.
Wrapper over QSqlQuery::lastError()
|
inline |
Returns the text of the current query being used, or an empty string if there is no current query text.
Wrapper over QSqlQuery::lastQuery()
|
inline |
Retrieves the next record in the result, if available, and positions the query on the retrieved record.
Wrapper over QSqlQuery::next()
|
inline |
Discards the current result set and navigates to the next if available (if database is capable of returning multiple result sets)
Wrapper over QSqlQuery::nextResult()
|
inline |
Returns the number of rows affected by the result's SQL statement, or -1 if it cannot be determined.
Wrapper over QSqlQuery::numRowsAffected()
|
inline |
Returns vector of (optionally parsed) integer values from currently active result row.
Parsing with specified base will be performed if type of selected database field is String (varchar/text). Not successfully parsed string values are ignored.
base | Number base to parse int values from SQL string values. |
skipNullValues | Skip SQL NULL values. Resulting int value is 0 if skipNullValues = false. |
|
inline |
Retrieves the previous record in the result, if available, and positions the query on the retrieved record.
Wrapper over QSqlQuery::previous()
|
inline |
Returns scalar value converted to type T (the value of the first column of the current row)
|
inline |
Returns scalar value (the value of the first column of the current row)
|
inline |
Retrieves the record at position index, if available, and positions the query on the retrieved record.
Wrapper over QSqlQuery::seek()
|
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.
Wrapper over QSqlQuery::size()
|
inline |
Returns QVariantList filled with values fetched from current result row.
|
inline |
Returns QVariantMap filled with values fetched from current result row. Key is QString (result column name) and value is QVariant value.
|
inline |
Returns QStringList filled with values fetched from current result row. SQL values converted to QString with QVariant::toString() method.
|
inline |
Returns QVector<QVariant> filled with values fetched from current result row. SQL values not converted: QSqlQuery::value() return value used.
|
inline |
Returns QVector<T> filled with values fetched from current result row. SQL values converted with QVariant::value<T>(). QVector::canConvert<T>() method used for convertability check. Non-convertable values skipped.
skipNullValues | Skip SQL NULL values. Resulting value is default value if skipNullValues = false. |
|
inline |
Returns reference on wrapped QSqlQuery.
|
inline |
Returns the value of field index in the current record.
Wrapper over QSqlQuery::value()
|
inline |
Returns the value of the field called name in the current record. If field name does not exist an invalid variant is returned.
Wrapper over QSqlQuery::value()
|
friend |
|
friend |
|
friend |