26 #ifndef ZSQLDATABASE_H 27 #define ZSQLDATABASE_H 33 #include <QSqlDatabase> 34 #include <QReadWriteLock> 35 #include <QObjectCleanupHandler> 36 #include <QStringList> 93 Tables = QSql::Tables,
94 SystemTables = QSql::SystemTables,
96 AllTables = QSql::AllTables,
106 LowPrecisionInt32 = QSql::LowPrecisionInt32,
107 LowPrecisionInt64 = QSql::LowPrecisionInt64,
108 LowPrecisionDouble = QSql::LowPrecisionDouble,
109 HighPrecision = QSql::HighPrecision
122 Q_PROPERTY(QString hostName READ getHostname WRITE setHostname)
130 Q_PROPERTY(QString databaseName READ getDbName WRITE setDbName)
138 Q_PROPERTY(
int portNumber READ getPortNumber WRITE setPortNumber)
144 Q_PROPERTY(QString connectOptions READ getConnectOptions
145 WRITE setConnectOptions)
161 Q_PROPERTY(
bool isOpen READ isOpen)
169 Q_PROPERTY(
bool isOpenError READ isOpenError)
191 bool isOpenError() const;
193 QString getHostname() const;
195 void setHostname(const QString& hostname);
197 QString getDbName() const;
199 void setDbName(const QString& hostname);
201 int getPortNumber() const;
203 void setPortNumber(
int);
205 void setConnectOptions(const QString& options);
207 QString getConnectOptions();
222 Q_INVOKABLE
bool open(const QString & user, const QString & password);
230 Q_INVOKABLE
void close();
245 Q_INVOKABLE QStringList getTableNames(
int tableType) const;
252 Q_INVOKABLE
bool transaction();
263 Q_INVOKABLE
bool commit();
274 Q_INVOKABLE
bool rollback();
290 Q_INVOKABLE QObject*
record(const QString& tablename);
315 static QObject* addDatabase(const QString& driverType,
316 const QString& connectionName );
331 static
void removeDatabase(const QString& connectionName );
339 static
void removeThreadDatabases();
355 static QObject* database(const QString& connectionName);
375 inline
void validateDb() const;
381 inline
void validateThread();
398 static ZsqlDbMap m_databaseObjects;
403 static QReadWriteLock m_lock;
419 throw ZblException(
"ZsqlDatabase objects should only be called from the " 420 "thread in which they were created.");
427 "Error: ZsqlDatabase's embedded QSqlDatabase object has already " 433 #endif // ZSQLDATABASE_H #define ZBLCORESHARED_EXPORT
void validateDb() const
Checks that the embedded QSqlDatabase object exists and throws a ZblException if not.
QObject lastError
Returns a ZsqlError object representing the last error encountered by this query. ...
void createTags()
Create the m_tag object that presents a Javascript interface for ZsqlQuery enumeration values...
QPointer< ZsqlQuery > ZsqlQueryPtr
QVariant tags
Obtains a javascript dictionary object that maps constants, enumerations and flags for use with ZsqlQ...
QVariant getTags()
Obtains a javascript dictionary object that maps constants, enumerations and flags for use with ZsqlQ...
A javascript wrapper class for QSqlDatabase objects. This object represents a database connection...
A javascript wrapper class for QSqlQuery objects. This object represents a query on a database connec...
static QVariant m_tags
A QVariantMap used to pass ZsqlQuery enumeration values to Javascript programs.
QMap< QString, ZsqlDatabase * > ZsqlDbMap
static ZsqlQuery * newQuery(ZsqlDatabase &database)
Constructs an empty ZsqlQuery object for the specified database connection.
bool inObjectThread(const QObject &object)
Zuble's Qt Exception Object.
Q_INVOKABLE QObject * record()
Obtains a ZsqlRecord object representing the query result.
QList< ZsqlQuery * > ZsqlQueryList
Q_INVOKABLE void release()
Releases references from this object to wrapped Qt C++ objects.