this class represents a comparison condition.
More...
#include <drogon/orm/Criteria.h>
|
| | operator bool () const |
| | Check if the condition is empty.
|
| std::string | criteriaString () const |
| | return the condition string in SQL.
|
| template<typename... Arguments> |
| | Criteria (const CustomSql &sql, Arguments &&...args) |
| | Construct a new custom Criteria object.
|
|
template<typename... Arguments> |
| | Criteria (CustomSql &&sql, Arguments &&...args) |
| template<typename T> |
| | Criteria (const std::string &colName, const CompareOperator &opera, T &&arg) |
| | Construct a new Criteria object.
|
|
template<typename T> |
| | Criteria (const std::string &colName, const CompareOperator &opera, const std::vector< T > &args) |
|
template<typename T> |
| | Criteria (const std::string &colName, const CompareOperator &opera, std::vector< T > &&args) |
|
template<typename T> |
| | Criteria (const std::string &colName, const CompareOperator &opera, std::vector< T > &args) |
| template<typename T> |
| | Criteria (const std::string &colName, T &&arg) |
| | Construct a new Criteria object presenting a equal expression.
|
| | Criteria (const std::string &colName, const CompareOperator &opera) |
| | Construct a new Criteria object presenting a expression without parameters.
|
|
| Criteria (const std::string &colName, CompareOperator &opera) |
|
| Criteria (const std::string &colName, CompareOperator &&opera) |
| | Criteria (const Json::Value &json) noexcept(false) |
| | Construct a new Criteria object.
|
| void | outputArgs (internal::SqlBinder &binder) const |
| | Output arguments to the SQL binder object.
|
this class represents a comparison condition.
◆ Criteria() [1/5]
template<typename... Arguments>
| drogon::orm::Criteria::Criteria |
( |
const CustomSql & | sql, |
|
|
Arguments &&... | args ) |
|
inlineexplicit |
Construct a new custom Criteria object.
- Parameters
-
| sql | The SQL statement to be executed. |
| args | The parameters to be passed to the placeholders. |
- Note
Use $? as placeholders in the SQL statement.
Be careful that the placeholders are not the same as the ones in functions such as drogon::orm::DbClient::execSqlAsync. Which means you couldn't use numeric placeholders such as $1, $2 to represent the order of the arguments.
The arguments should be in the same order as the placeholders.
◆ Criteria() [2/5]
template<typename T>
| drogon::orm::Criteria::Criteria |
( |
const std::string & | colName, |
|
|
const CompareOperator & | opera, |
|
|
T && | arg ) |
|
inline |
Construct a new Criteria object.
- Template Parameters
-
| T | the type of the object to be compared with. |
- Parameters
-
| colName | The name of the column. |
| opera | The type of the comparison. |
| arg | The object to be compared with. |
◆ Criteria() [3/5]
template<typename T>
| drogon::orm::Criteria::Criteria |
( |
const std::string & | colName, |
|
|
T && | arg ) |
|
inline |
Construct a new Criteria object presenting a equal expression.
- Template Parameters
-
| T | The type of the object to be equal to. |
- Parameters
-
| colName | The name of the column. |
| arg | The object to be equal to. |
◆ Criteria() [4/5]
| drogon::orm::Criteria::Criteria |
( |
const std::string & | colName, |
|
|
const CompareOperator & | opera ) |
|
inline |
Construct a new Criteria object presenting a expression without parameters.
- Parameters
-
| colName | The name of the column. |
| opera | The type of the comparison. it must be one of the following: CompareOperator::IsNotNull
CompareOperator::IsNull
|
◆ Criteria() [5/5]
| drogon::orm::Criteria::Criteria |
( |
const Json::Value & | json | ) |
|
|
explicit |
Construct a new Criteria object.
- Parameters
-
| json | A json object representing the criteria |
- Note
- the json object must be a array of three items, the first is the name of the field, the second is the comparison operator and the third is the value to be compared. The valid operators are "=","<",">","<=",">=","!=","in" for example: ["id","=",1] means 'id = 1' ["id","!=",null] means 'id is not null' ["user_name","in",["Tom","Bob"]] means 'user_name in ('Tom', 'Bob')' ["price","<",1000] means 'price < 1000'
◆ criteriaString()
| std::string drogon::orm::Criteria::criteriaString |
( |
| ) |
const |
|
inline |
return the condition string in SQL.
- Returns
- std::string
◆ operator bool()
| drogon::orm::Criteria::operator bool |
( |
| ) |
const |
|
inlineexplicit |
Check if the condition is empty.
- Returns
- true means the condition is not empty.
-
false means the condition is empty.
◆ outputArgs()
Output arguments to the SQL binder object.
- Parameters
-
| binder | The SQL binder object. |
- Note
- This method must be called by drogon.
The documentation for this class was generated from the following file: