Revision a604a5a2
Von Christian Ehringfeld vor mehr als 9 Jahren hinzugefügt
example/.gitignore | ||
---|---|---|
*.pro.user
|
||
*build
|
src/database.cpp | ||
---|---|---|
}
|
||
|
||
|
||
int Database::getDatabaseType() {
|
||
DatabaseType Database::getDatabaseType() {
|
||
return CuteEntityManager::getDatabaseType(this->database.driverName());
|
||
}
|
||
|
src/database.h | ||
---|---|---|
void refreshTableList();
|
||
bool containsTable(QString tblname);
|
||
bool updateSequenceCounter(QSqlQuery &q);
|
||
int getDatabaseType();
|
||
DatabaseType getDatabaseType();
|
||
QChar escapeChar();
|
||
};
|
||
}
|
src/enums/databasetype.h | ||
---|---|---|
#include <QString>
|
||
#include "../schema.h"
|
||
#include "../schema/sqliteschema.h"
|
||
#include "../schema/pgsqlschema.h"
|
||
#include "../schema/mysqlschema.h"
|
||
#include <memory>
|
||
|
||
namespace CuteEntityManager {
|
||
enum DatabaseType {
|
||
SQLITE=0,
|
||
... | ... | |
MYSQL=2
|
||
};
|
||
|
||
static const int getDatabaseType(QString s) {
|
||
static const DatabaseType getDatabaseType(QString s) {
|
||
if(s == "qmysql") {
|
||
return CuteEntityManager::MYSQL;
|
||
} else if(s == "qpgsql") {
|
||
return CuteEntityManager::PGSQL;
|
||
} else if(s == "qsqlite"){
|
||
} else {
|
||
return CuteEntityManager::SQLITE;
|
||
}
|
||
}
|
||
|
||
static const Schema getSchema(int db) {
|
||
static const std::shared_ptr<Schema> getSchema(int db) {
|
||
switch (db) {
|
||
case SQLITE:
|
||
return SqliteSchema();
|
||
return std::shared_ptr<Schema>(new SqliteSchema());
|
||
break;
|
||
case PGSQL:
|
||
return std::shared_ptr<Schema>(new PgSqlSchema());
|
||
break;
|
||
case MYSQL:
|
||
return std::shared_ptr<Schema>(new MysqlSchema());
|
||
break;
|
||
default:
|
||
return SqliteSchema();
|
||
return std::shared_ptr<Schema>(new SqliteSchema());
|
||
break;
|
||
}
|
||
}
|
src/schema.cpp | ||
---|---|---|
|
||
}
|
||
|
||
QString Schema::quoteSimpleTableName(QString name) {
|
||
// return strpos($name, "`") !== false ? $name : "`" . $name . "`";
|
||
}
|
||
|
||
QString Schema::quoteSimpleColumnName(QString name)
|
||
{
|
||
//return strpos($name, '`') !== false || $name === '*' ? $name : '`' . $name . '`';
|
||
}
|
||
|
src/schema.h | ||
---|---|---|
const QString TYPE_BINARY = "binary";
|
||
const QString TYPE_BOOLEAN = "boolean";
|
||
const QString TYPE_MONEY = "money";
|
||
|
||
// /**
|
||
// * @var array list of ALL table names in the database
|
||
// */
|
||
// private $_tableNames = [];
|
||
// /**
|
||
// * @var array list of loaded table metadata (table name => TableSchema)
|
||
// */
|
||
// private $_tables = [];
|
||
// /**
|
||
// * @var QueryBuilder the query builder for this database
|
||
// */
|
||
// private $_builder;
|
||
|
||
|
||
virtual QHash<QString, QString> *getTypeMap() = 0;
|
||
virtual QString quoteSimpleTableName(QString name);
|
||
virtual QString quoteSimpleColumnName(QString name);
|
||
virtual QList<TableSchema> getTableSchemas(QString schema = "", bool refresh = false);
|
||
virtual QList<QString> getTableNames(QString schema = "", $refresh = false);
|
||
//virtual QueryBuilder getQueryBuilder();
|
||
//virtual QueryBuilder createQueryBuilder();
|
||
virtual QList<QString> findUniqueIndexes(TableSchema schema);
|
||
virtual QString getLastInsertID(QString sequenceName = "");
|
||
virtual void refresh();
|
||
|
||
protected:
|
||
virtual QList<QString> findTableNames(QString schema = "");
|
||
... | ... | |
virtual QString getCreateTableSql(TableSchema ts);
|
||
virtual bool findColumns(TableSchema ts);
|
||
QSharedPointer<QHash<QString, QString>> typeMap;
|
||
virtual TableSchema loadTableSchema(QString name) = 0;
|
||
virtual TableSchema getTableSchema(QString name, bool refresh = false);
|
||
virtual QList<QString> findTableNames(QString schema = "");
|
||
|
||
};
|
||
}
|
Auch abrufbar als: Unified diff
...