TSqlWhereSimpleV2 Class

TSqlWhereSimpleV2; More...

Header: #include <TSqlWhereSimpleV2>
Inherits: TSqlWhereAbsV2

Public Functions

TSqlWhereSimpleV2()
TSqlWhereSimpleV2(const QString &iField, const QVariant &iValue, const QString &iOperator = "=")
TSqlWhereSimpleV2(const TSqlWhereSimpleV2 &iOther)
~TSqlWhereSimpleV2()
QString databaseType() const
QString field() const
QString getOperator() const
TSqlWhereSimpleV2 &setDatabaseType(const QString &iDatabaseType)
TSqlWhereSimpleV2 &setField(const QString &iField)
TSqlWhereSimpleV2 &setOperator(const QString &iOperator)
TSqlWhereSimpleV2 &setValue(const QVariant &iValue)
QVariant value() const
TSqlWhereSimpleV2 &operator=(const TSqlWhereSimpleV2 &iOther)

Reimplemented Public Functions

virtual TSqlWhereSimpleV2 *clone() const
virtual QString toSql() const

Detailed Description

TSqlWhereSimpleV2;

Member Function Documentation

TSqlWhereSimpleV2::TSqlWhereSimpleV2()

Default constructs an instance of TSqlWhereSimpleV2.

TSqlWhereSimpleV2::TSqlWhereSimpleV2(const QString &iField, const QVariant &iValue, const QString &iOperator = "=")

构造函数 iField 数据库字段 iValue 字段对应的值 iOperator 操作符 例如:“where id > 233”


  TSqlWhereSimpleV2 where{"id", QVariant(233), ">");

TSqlWhereSimpleV2::TSqlWhereSimpleV2(const TSqlWhereSimpleV2 &iOther)

复制构造函数

TSqlWhereSimpleV2::~TSqlWhereSimpleV2()

Destroys the instance of TSqlWhereSimpleV2.

[virtual] TSqlWhereSimpleV2 *TSqlWhereSimpleV2::clone() const

Reimplemented from TSqlWhereAbsV2::clone().

返回一个副本指针

Note: 这个指针需要有调用者释放

QString TSqlWhereSimpleV2::databaseType() const

返回数据库类型

See also setDatabaseType().

QString TSqlWhereSimpleV2::field() const

返回字段

See also setField().

QString TSqlWhereSimpleV2::getOperator() const

See also setOperator() and ;.

TSqlWhereSimpleV2 &TSqlWhereSimpleV2::setDatabaseType(const QString &iDatabaseType)

设置数据库类型,如设置PostgreSQL


  setDatabaseType("QPSQL");

See also databaseType().

TSqlWhereSimpleV2 &TSqlWhereSimpleV2::setField(const QString &iField)

设置字段

See also field().

TSqlWhereSimpleV2 &TSqlWhereSimpleV2::setOperator(const QString &iOperator)

设置操作符(=、!=、==、LIKE、 NOT LIKE、>、<)

See also toSql() and ;.

TSqlWhereSimpleV2 &TSqlWhereSimpleV2::setValue(const QVariant &iValue)

设置‘值’

See also value().

[virtual] QString TSqlWhereSimpleV2::toSql() const

Reimplemented from TSqlWhereAbsV2::toSql().

返回拼接的SQL Where语句,例如:


  TSqlWhereSimpleV2 where{"id", QVariantList(233, 666), "="}
  where.toSql(); // "where id in(233, 666)"


  TSqlWhereSimpleV2 where{"id", QVariant(233), "=="};
  where.toSql(); // "where id = 233"

同理,如果操作符为"!=" ,根据比较值的不同为分别产出"!=""NOT IN" - 如果值是无效Variant或者为Null,那么 "=""!=" 将产出 "IS NULL" 和 "NOT NULL" - 如果操作符为 "LIKE""NOT LIKE",当比较值为列表时会使用"OR" 进行连接,否则按照 field + operator + value拼接 - 其他操作符按照 field + operator + value拼接

See also TSqlWhereSimpleV2::TSqlWhereSimpleV2(const QString &iField, const QVariant &iValue, const QString &iOperator).

QVariant TSqlWhereSimpleV2::value() const

返回‘值’

See also setValue().

TSqlWhereSimpleV2 &TSqlWhereSimpleV2::operator=(const TSqlWhereSimpleV2 &iOther)

赋值函数