Revision 358e1e04
Von Christian Ehringfeld vor mehr als 8 Jahren hinzugefügt
src/querybuilder.cpp | ||
---|---|---|
return exp;
|
||
}
|
||
|
||
Expression QueryBuilder::where(QString column, QVariant value) {
|
||
QString placeholder = column + "_where";
|
||
Expression exp = Expression(this->schema->quoteColumnName(column) + "=" +
|
||
this->placeHolder(placeholder));
|
||
exp.appendParam(placeholder, value);
|
||
return exp;
|
||
}
|
||
|
||
Join QueryBuilder::joinClasses(const QSharedPointer<Entity> &mainEntity,
|
||
const QSharedPointer<Entity> &foreignEntity, const QString &joinType) const {
|
||
Join j = Join(foreignEntity->getTablename(),
|
||
... | ... | |
return joined;
|
||
}
|
||
|
||
//QHash<QString, QVariant> values
|
||
|
||
Expression QueryBuilder::where(QHash<QString, QVariant> conditions,
|
||
QString conjunction) const {
|
||
Expression exp = Expression(this->where(conditions, conjunction, false, "id",
|
||
... | ... | |
return exp;
|
||
}
|
||
|
||
Expression QueryBuilder::where(QString condition,
|
||
QHash<QString, QVariant> values) const {
|
||
Expression exp = Expression(condition);
|
||
for (auto i = values.constBegin(); i != values.constEnd(); ++i) {
|
||
exp.appendParam(i.key(), i.value());
|
||
Expression QueryBuilder::where(QString c, QVariant value) {
|
||
Expression exp;
|
||
if(value.type() == QVariant::Hash) {
|
||
auto values = value.toHash();
|
||
exp = Expression(c);
|
||
for (auto i = values.constBegin(); i != values.constEnd(); ++i) {
|
||
exp.appendParam(i.key(), i.value());
|
||
}
|
||
} else {
|
||
QString placeholder = c + "_where";
|
||
exp = Expression(this->schema->quoteColumnName(c) + "=" +
|
||
this->placeHolder(placeholder));
|
||
exp.appendParam(placeholder, value);
|
||
}
|
||
return exp;
|
||
}
|
Auch abrufbar als: Unified diff
more comfort for query class