Revision 9e44a59b
Von Christian Ehringfeld vor etwa 10 Jahren hinzugefügt
| samples/example/main.cpp | ||
|---|---|---|
|
}
|
||
|
qDebug() << "-----------------------------";
|
||
|
|
||
|
QHash<QString,QVariant> attributes;
|
||
|
attributes["name"]=QString("05c");
|
||
|
e->findEntityByAttributes<Pupil>(attributes);
|
||
|
|
||
|
|
||
|
qDebug() << "Duration:" << t.elapsed();
|
||
|
return 0;
|
||
|
}
|
||
| src/entitymanager.h | ||
|---|---|---|
|
template<class T> QList<QSharedPointer<T>> findAllEntitiesByAttributes(
|
||
|
const QHash<QString, QVariant> &attributes =
|
||
|
QHash<QString, QString>(), quint64 limit = 0, quint64 offset = 0) {
|
||
|
QSharedPointer<T> e = QSharedPointer<T>
|
||
|
QSharedPointer<Entity> e = QSharedPointer<Entity>
|
||
|
(EntityInstanceFactory::createInstance<T *>());
|
||
|
if (e) {
|
||
|
Query query = Query(QStringList(e->getTablename()),
|
||
|
this->schema->getQueryBuilder()->where(attributes));
|
||
|
Query query = Query(QStringList(e->getTablename()));
|
||
|
query.appendWhere(this->schema->getQueryBuilder()->where(attributes));
|
||
|
query.setLimit(limit);
|
||
|
query.setOffset(offset);
|
||
|
QSqlQuery q = this->queryInterpreter->build(query);
|
||
| ... | ... | |
|
auto list = this->convert(results, EntityHelper::getClassname(e.data()));
|
||
|
return this->convertList<T>(list);
|
||
|
}
|
||
|
return QList<QSharedPointer<Entity>>();
|
||
|
return QList<QSharedPointer<T>>();
|
||
|
}
|
||
|
|
||
|
template<class T> QList<QSharedPointer<T>> findEntitiesBySql(
|
||
| src/query.h | ||
|---|---|---|
|
public:
|
||
|
Query();
|
||
|
~Query();
|
||
|
Query(QStringList from, QList<Expression> where,
|
||
|
Query(QStringList from, QList<Expression> where = QList<Expression>(),
|
||
|
QList<Join> joins = QList<Join>(),
|
||
|
QHash<QString, QVariant> params = QHash<QString, QVariant>(), quint64 limit = 0,
|
||
|
quint64 offset = 0,
|
||
| src/queryinterpreter.cpp | ||
|---|---|---|
|
expression = this->builder->getSchema()->quoteTableName(expression);
|
||
|
} else if (count == 1) {
|
||
|
QStringList list = expression.split("=");
|
||
|
expression = this->builder->getSchema()->quoteTableName(list.at(
|
||
|
expression = this->builder->getSchema()->quoteColumnName(list.at(
|
||
|
0).trimmed()) + " = ";
|
||
|
expression += this->builder->getSchema()->quoteTableName(list.at(1).trimmed());
|
||
|
expression += this->builder->getSchema()->quoteColumnName(list.at(1).trimmed());
|
||
|
}
|
||
|
sqlJoin += " ON " + expression;
|
||
|
}
|
||
Auch abrufbar als: Unified diff
fix