TDbActiveQuery


This template class represent high level abstraction for querying from database operation and works directly with Active Record models.

You can find more information in comments below.

template<class Type>
class TDbActiveQuery :public virtual IDbQuery, public CReleasable
{
public:
    TDbActiveQuery() :

    TDbActiveQuery* Select(const String& column); // Add column to be selected from DB 
    TDbActiveQuery* Select(const String& column, const String& alias); // Add column with alias to be selected from DB 
    TDbActiveQuery* Select(const StringKeyValue& column); // Add column with alias to be selected from DB 
    TDbActiveQuery* Select(const StringArray& columns); // Add columns to be selected from DB 
    TDbActiveQuery* Select(const StringKeyValueArray& columns); // Add columns with alias to be selected from DB 
    TDbActiveQuery* Distinct(const bool& value); // Sets whether only unique values should be selected 
    TDbActiveQuery* From(const String& table); // Add table from which data is to be selected 
    TDbActiveQuery* From(const String& table, const String& alias); // Add table with alias from which data is to be selected 
    TDbActiveQuery* From(const StringArray& tables); // Add tables from which data is to be selected 
    TDbActiveQuery* From(const StringKeyValueArray& tables); // Add tables with aliases from which data is to be selected 
    TDbActiveQuery* InnerJoin(const String& table, DbCondition on); // Add inner join table condition 
    TDbActiveQuery* InnerJoin(const String& table, const String& alias, DbCondition on); // Add inner join table with alias condition 
    TDbActiveQuery* InnerJoin(const DbJoin& table); // Add inner join table 
    TDbActiveQuery* LeftJoin(const String& table, DbCondition on); // Add left join table condition 
    TDbActiveQuery* LeftJoin(const String& table, const String& alias, DbCondition on); // Add left join table with alias condition 
    TDbActiveQuery* LeftJoin(const DbJoin& table); // Add left join table 
    TDbActiveQuery* RightJoin(const String& table, DbCondition on); // Add right join table condition 
    TDbActiveQuery* RightJoin(const String& table, const String& alias, DbCondition on); // Add right join table with alias condition 
    TDbActiveQuery* RightJoin(const DbJoin& table); // Add right join table 
    TDbActiveQuery* Where(DbCondition condition); // Set query condition 
    TDbActiveQuery* Where(const DbConditions &conditions); // Set query conditions joined by AND operator 
    TDbActiveQuery* AndWhere(DbCondition condition); // Add query condition joining by AND operator 
    TDbActiveQuery* OrWhere(DbCondition condition); // Add query condition joining by OR operator 
    TDbActiveQuery* GroupBy(const String& column); // Add grouping by column 
    TDbActiveQuery* GroupBy(const StringArray& columns); // Add grouping by columns 
    TDbActiveQuery* Having(DbCondition condition); // Set filter condition 
    TDbActiveQuery* Having(const DbConditions &conditions); // Set filter conditions joining by AND operator 
    TDbActiveQuery* AndHaving(DbCondition condition); // Add filter condition joining by AND operator 
    TDbActiveQuery* OrHaving(DbCondition condition); // Add filter condition joining by OR operator 
    TDbActiveQuery* OrderBy(const String& column, const DbOrder& order); // Add ordering by column 
    TDbActiveQuery* OrderBy(const DbOrderByArray& columns); // Add ordering by columns 
    TDbActiveQuery* Limit(const int64& limit = -1); // Set result maximum allowed record count. -1 means no limit or all records will be returned 
    TDbActiveQuery* Offset(const int64& offset = -1); // Set result offset or at which record start to get records. -1 means no offset or from the beginning 
    TDbActiveQuery* Union(ReleasablePtr<IDbQuery> query, const bool all = false); // Set union query 

    DbValue Column(); // Executes the query and returns the first column of the result. Throw exceptions in case of error 
    int64 Count(const String& column = L"*"); // Returns the number of records. Throw exceptions in case of error 
    bool Exists(); // Return whether there is any records in query stored in this object or not. Throw exceptions in case of error 
    template<class ScalarType> ScalarType Scalar(const String& column); // Returns the query result as a scalar value. Throw exceptions in case of error 
    template<class ResultType> ResultType Sum(const String& column); // Returns the sum of the specified column values. Throw exceptions in case of error 
    template<class ResultType> ResultType Average(const String& column); // Returns the average of the specified column values. Throw exceptions in case of error 
    template<class ResultType> ResultType Min(const String& column); // Returns the minimum of the specified column values. Throw exceptions in case of error 
    template<class ResultType> ResultType Max(const String& column); // Returns the maximum of the specified column values. Throw exceptions in case of error 
    Models All(); // Executes the query and returns all unique (by primary key) results as model array. Throw exceptions in case of error 
    Model One(); // Executes the query and returns a single row of result as a model. Throw exceptions in case of error 
};
Namespace: nitisa
Include: Nitisa/Db/DbActiveQuery.h