Loading...
Searching...
No Matches
tsqlormapper.h
Go to the documentation of this file.
465 query += TSqlQuery::escapeIdentifier(rec.fieldName(i), QSqlDriver::FieldName, database().driver());
587 upd += TSqlQuery::escapeIdentifier(QLatin1String(propName), QSqlDriver::FieldName, db.driver());
The TAbstractSqlORMapper class is the abstract base class of functionality to object-relational mappi...
Definition tsqlormapper.h:20
virtual int findCount(const TCriteria &cri=TCriteria())=0
virtual void setOffset(int offset)=0
virtual int findCountBy(int column, const QVariant &value)=0
virtual int updateAll(const TCriteria &cri, const QMap< int, QVariant > &values)=0
virtual int updateAll(const TCriteria &cri, int column, const QVariant &value)=0
virtual void reset()=0
virtual int find(const TCriteria &cri=TCriteria())=0
virtual void setLimit(int limit)=0
virtual ~TAbstractSqlORMapper()
Definition tsqlormapper.h:23
TAbstractSqlORMapper(const QSqlDatabase &db)
Definition tsqlormapper.h:22
virtual void setSortOrder(const QString &column, Tf::SortOrder order=Tf::AscendingOrder)=0
virtual int removeAll(const TCriteria &cri=TCriteria())=0
virtual void setSortOrder(int column, Tf::SortOrder order=Tf::AscendingOrder)=0
virtual int findIn(int column, const QVariantList &values)=0
virtual int findBy(int column, const QVariant &value)=0
The TCriteria class represents a WHERE clause without SQL for the sake of database abstraction.
Definition tcriteria.h:6
bool isEmpty() const
Returns true if the criteria has no data; otherwise returns false.
Definition tcriteria.cpp:345
The TSqlJoin class represents JOIN clause for combination to a record of other table.
Definition tsqljoin.h:14
bool operator!=(const ConstIterator &o) const
Definition tsqlormapper.h:114
bool operator==(const ConstIterator &o) const
Definition tsqlormapper.h:113
ConstIterator & operator=(const ConstIterator &o)
Definition tsqlormapper.h:106
ConstIterator(const ConstIterator &o)
Definition tsqlormapper.h:104
The TSqlORMapper class is a template class that provides concise functionality to object-relational m...
Definition tsqlormapper.h:53
int findIn(int column, const QVariantList &values)
Retrieves with the criteria that the column is within the list of values values returns the number of...
Definition tsqlormapper.h:280
virtual void clear()
Clears and releases any acquired resource.
Definition tsqlormapper.h:724
int find(const TCriteria &cri=TCriteria())
Retrieves with the criteria cri from the table and returns the number of the ORM objects.
Definition tsqlormapper.h:241
virtual QString selectStatement() const
Returns a SELECT statement generated from the specified parameters.
Definition tsqlormapper.h:450
T value(int i) const
Returns the ORM object in the results retrieved by find() function.
Definition tsqlormapper.h:329
T findFirst(const TCriteria &cri=TCriteria())
Returns the first ORM object retrieved with the criteria cri from the table.
Definition tsqlormapper.h:187
void setJoin(int column, const TSqlJoin< C > &join)
Sets a JOIN clause for column to join.
Definition tsqlormapper.h:659
void setSortOrder(int column, Tf::SortOrder order=Tf::AscendingOrder)
Sets the sort order for column to order.
Definition tsqlormapper.h:364
T last() const
Returns the last ORM object in the results retrieved by find() function.
Definition tsqlormapper.h:318
int findBy(int column, const QVariant &value)
Retrieves with the criteria for the column as the value in the table and returns the number of the OR...
Definition tsqlormapper.h:268
int findCount(const TCriteria &cri=TCriteria())
Returns the number of records retrieved with the criteria cri from the table.
Definition tsqlormapper.h:521
T findFirstBy(int column, const QVariant &value)
Returns the first ORM object retrieved with the criteria for the column as the value in the table.
Definition tsqlormapper.h:213
int rowCount() const
Returns the number of rows of the current query.
Definition tsqlormapper.h:289
void setOffset(int offset)
Sets the offset to offset, which is the number of rows to skip for execution of SELECT statement.
Definition tsqlormapper.h:355
TSqlORMapper< T > & join(int column, const TSqlJoin< C > &join)
Definition tsqlormapper.h:705
int findCountBy(int column, const QVariant &value)
Returns the number of records retrieved with the criteria for the column as the value from the table.
Definition tsqlormapper.h:551
void setLimit(int limit)
Sets the limit to limit, which is the limited number of rows for execution of SELECT statement.
Definition tsqlormapper.h:345
int updateAll(const TCriteria &cri, int column, const QVariant &value)
Updates the value of the specified column in all rows that satisfy the criteria cri and returns the n...
Definition tsqlormapper.h:621
void reset()
Reset the internal state of the mapper object.
Definition tsqlormapper.h:715
int removeAll(const TCriteria &cri=TCriteria())
Removes all rows based on the criteria cri from the table and returns the number of the rows affected...
Definition tsqlormapper.h:633
T first() const
Returns the first ORM object in the results retrieved by find() function.
Definition tsqlormapper.h:308
void setFilter(const QString &filter)
Sets the current filter to filter.
Definition tsqlormapper.h:440
QString orderBy() const
Returns a SQL WHERE clause generated from a criteria.
Definition tsqlormapper.h:743
T findByPrimaryKey(const QVariant &pk)
Returns the ORM object retrieved with the primary key pk from the table.
Definition tsqlormapper.h:223
TSqlORMapper< T > & offset(int offset)
Sets the offset to offset, which is the number of rows to skip for execution of SELECT statement.
Definition tsqlormapper.h:407
TSqlORMapper< T > & limit(int limit)
Sets the limit to limit, which is the limited number of rows for execution of SELECT statement.
Definition tsqlormapper.h:396
The TSqlQuery class provides a means of executing and manipulating SQL statements.
Definition tsqlquery.h:6
QVariant value(int index) const
Returns the value of field index in the current record.
Definition tsqlquery.h:68
bool exec(const QString &query)
Executes the SQL in query.
Definition tsqlquery.cpp:200
int numRowsAffected() const
Returns the number of rows affected by the result's SQL statement, or -1 if it cannot be determined.
Definition tsqlquery.h:50
static QString formatValue(const QVariant &val, const QMetaType &type, int databaseId=0)
Returns a string representation of the value val for the database databaseId.
Definition tsqlquery.cpp:125
static QString escapeIdentifier(const QString &identifier, QSqlDriver::IdentifierType type=QSqlDriver::FieldName, int databaseId=0)
Returns the identifier escaped according to the rules of the database databaseId.
Definition tsqlquery.cpp:102
bool next()
Retrieves the next record in the result, if available, and positions the query on the retrieved recor...
Definition tsqlquery.h:62
The Tf namespace contains miscellaneous identifiers used throughout the library of TreeFrog Framework...
Definition tdebug.h:10
T_CORE_EXPORT void writeQueryLog(const QString &query, bool success, const QSqlError &error, int duration)
Definition tsystemglobal.cpp:144
void warn(const std::format_string< Args... > &fmt, Args &&... args)
Outputs the warning message to the log file, formatting args according to the format string fmt.
Definition tglobal.h:259
QSqlError lastError()
Returns the VariantMap object of the error status of the last operation.
Definition tcachesqlitestore.cpp:26
const QByteArray ModifiedAt("modifiedAt")
const QByteArray UpdatedAt("updatedAt")
void tSystemDebug(const std::format_string< Args... > &fmt, Args &&... args)
Definition tsystemglobal.h:108
void tSystemError(const std::format_string< Args... > &fmt, Args &&... args)
Definition tsystemglobal.h:59
