Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision dc618bda

Von Christian Ehringfeld vor mehr als 9 Jahren hinzugefügt

  • ID dc618bda3a4c559d6a90f8617cedd2450a25c7db
  • Vorgänger 1b167b6c
  • Nachfolger 9fccde32

fix

Unterschiede anzeigen:

src/entitymanager.h
namespace CuteEntityManager {
class Logger;
class QueryInterpreter;
class EntityManager : public QObject {
......
public:
public:
EntityManager(QSqlDatabase database);
EntityManager(const QString &databaseType, QString databasename = "" ,
QString hostname = "",
QString username = "",
QString password = "", QString port = "", bool logQueries = false);
~EntityManager();
static QStringList getConnectionNames();
/**
* @brief startup
* @param version must be unique
* @param toInitialize list of entity classnames which database tables should be created
* @return
*/
QSharedPointer<QueryBuilder> getQueryBuilder() const;
public:
EntityManager(QSqlDatabase database);
EntityManager(const QString &databaseType, QString databasename = "" ,
QString hostname = "",
QString username = "",
QString password = "", QString port = "", bool logQueries = false);
~EntityManager();
static QStringList getConnectionNames();
/**
* @brief startup
* @param version must be unique
* @param toInitialize list of entity classnames which database tables should be created
* @return
*/
QSharedPointer<QueryBuilder> getQueryBuilder() const;
template<class T> QList<QSharedPointer<T>> find(Query &q) {
QSharedPointer<Entity> ptr = QSharedPointer<Entity>
......
q.setFrom(QStringList(ptr->getTablename()));
}
QSqlQuery query = this->queryInterpreter->build(q);
this->db->select(query);
auto maps = this->convertQueryResult(query);
auto converted = this->convert(maps, EntityHelper::getClassname(ptr.data()));
return this->convertList<T>(converted);
......
query.setLimit(limit);
query.setOffset(offset);
QSqlQuery q = this->queryInterpreter->build(query);
this->db->select(q);
auto results = this->convertQueryResult(q);
auto list = this->convert(results, EntityHelper::getClassname(e.data()));
return this->convertList<T>(list);
......
const QString &sql) {
QSharedPointer<T> e = EntityInstanceFactory::createInstance<T *>();
if (e) {
QSqlQuery q = this->db->select(sql);
QSqlQuery q = this->schema->getDatabase()->getQuery(sql);
auto result = this->convertQueryResult(q);
auto converted = this->convert(result, EntityHelper::getClassname(e));
return this->convertList<T>(converted);
src/query.cpp
#include "query.h"
#include "orderby.h"
#include <QDebug>
using namespace CuteEntityManager;
Query::Query() {
//this->select << Expression("*");
}
Query::Query(QStringList from, QList<Expression> where, QList<Join> joins,
src/queryinterpreter.cpp
#include "orderby.h"
#include "expression.h"
#include "schema.h"
#include <QDebug>
using namespace CuteEntityManager;
......
q.getOffset());
QSqlQuery sqlQuery = this->builder->getQuery();
sqlQuery.prepare(sql);
qDebug() << "--------------------------------------";
for (auto i = q.getParams().constBegin(); i != q.getParams().constEnd(); ++i) {
qDebug() << i.key() << i.value();
}
qDebug() << "--------------------------------------";
this->builder->bindValues(q.getParams(), sqlQuery, false);
return sqlQuery;
}
......
}
}
sqlCondition += expression;
q.appendParams(q.getParams());
q.appendParams(exp.getParams());
}
return sqlCondition;
}

Auch abrufbar als: Unified diff