Revision e86c23a2
Von Christian Ehringfeld vor fast 9 Jahren hinzugefügt
src/querybuilder.cpp | ||
---|---|---|
QueryBuilder::~QueryBuilder() {
|
||
}
|
||
|
||
bool QueryBuilder::createTable(const QSharedPointer<Entity> &entity) const {
|
||
bool QueryBuilder::createTable(const QSharedPointer<Entity> &entity, bool createRelationTables) const {
|
||
bool rc = false;
|
||
if (entity.data()) {
|
||
auto tableDefinition = this->generateTableDefinition(entity);
|
||
... | ... | |
if (!rc) {
|
||
QSqlQuery q = this->database.data()->getQuery(this->createTable(tableName,
|
||
tableDefinition));
|
||
|
||
|
||
if (this->database.data()->transaction(q)) {
|
||
if(createRelationTables) {
|
||
auto relTables = this->generateRelationTables(entity);
|
||
auto i = relTables.constBegin();
|
||
while(i != relTables.constEnd()) {
|
||
this->createTable(i.key(),i.value());
|
||
++i;
|
||
}
|
||
}
|
||
this->schema.data()->getTableSchema(tableName);
|
||
rc = true;
|
||
if (rc) {
|
||
... | ... | |
const QSharedPointer<Entity> &entity, qint64 offset, QString pk) const {
|
||
QSqlQuery q = this->database.data()->getQuery(this->selectBase(QStringList(
|
||
entity.data()->getTablename())) + this->joinSuperClasses(
|
||
entity) + " WHERE " + pk + "= :id" + this->limit(1, offset));
|
||
entity) + " WHERE " + this->schema.data()->quoteColumnName(pk) + "= :id" + this->limit(1, offset));
|
||
q.bindValue(":id", id);
|
||
return q;
|
||
}
|
Auch abrufbar als: Unified diff
quoting